在div中包含一个网页 [英] Include a webpage inside a div

查看:117
本文介绍了在div中包含一个网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在我的网页div中包含一个网页。我想要使​​用 iframe 来处理 DIV 。基本上,我将为我的div提供一个URL,并且必须在其内部打开它...在现代HTML中,我们是否有这样的东西?我不能使用框架,因为一些浏览器对框架有问题。

解决方案

不。您不能在另一个div元素中嵌入完整的HTML文档,因为这是块级元素,W3C已经定义了可以包含在其中的内容。



但有一个解决方法。请按照以下步骤操作:


  1. 使用ajax获取文档(使用jQuery文件)

  2. < body> 元素的内容并将其放入您的 div 元素中

  3. 获取< head> 元素的所有链接和脚本,并将它们追加到< head> 元素您现有的pgae。


I have to include a webpage inside my webpage's div. I want somehting like iframe to be done with DIV. Basically, I will be providing a URL to my div and it has to open it inside itself... Do we have something like this in modern HTML? I cannot use frames as some browsers have issues with frames.

解决方案

Nope. You can't embed a complete HTML document inside another div element as this is a block level element and W3C has defined what could be included inside it.

But there is a workaround. Follow these steps:

  1. Get the document using ajax (jQuery rocks, use that)
  2. Extract the content of the <body> element and put it inside your div element
  3. Get all links and script of <head> element and append them to the <head> element of your existing pgae.

这篇关于在div中包含一个网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆