使用 iframe 或 Object 标签将网页嵌入到另一个网页中 [英] Use of Iframe or Object tag to embed web pages in another

查看:41
本文介绍了使用 iframe 或 Object 标签将网页嵌入到另一个网页中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我在工作中维护的一个基于 Web 的系统中,它最近上线了,它创建了一个 Object 元素以在主网页中嵌入第二个网页.(实际上主网页包含菜单和标题,主应用程序页面在对象中)

In a web-based system I maintain at work that recently went live, it makes an Object element to embed a second web page within the main web page. (Effectively the main web page contains the menu and header, and the main application pages are in the object)

例如

<object id="contentarea" standby="loading data, please wait..."  
    title="loading data, please wait..." width="100%" height="53%" 
    type="text/html" data="MainPage.aspx"></object>

此应用程序的旧版本使用 IFRAME 来执行此操作.我发现通过使用对象标签,嵌入网页的行为与之前在 IFRAME 中托管时的行为不同.例如,在 IE 中,工具提示不起作用(我将发布一个关于此的单独问题!),并且看起来嵌入的页面无法访问脚本中的父页面,但如果它是 IFRAME 则可以.

Older versions of this application use an IFRAME to do this though. I have found that by using the object tag the embedded web page behaves differently to when it was previously hosted in an IFRAME. In IE, for example, the tool tips don't seen to work (I will post a separate question about this!), and it looks like the embedded page cannot access the parent page in script, although it can if it was an IFRAME.

有人告诉我,使用对象标签而不是 IFRAME 的原因是 IFRAME 已被弃用,因此不能依赖于未来版本的浏览器.这是真的吗?在 Iframe 上使用 Object 标签来嵌入网页是否更可取?或者,IFRAME 将来是否有可能得到很好的支持(在我年老体衰、超过我维护的应用程序的使用寿命很久之后)?

I am told the reason for favouring the object tag over the IFRAME is that the IFRAME is being deprecated and so cannot be relied on for future versions of browsers. Is this true though? Is it preferable to use the Object tag over the Iframe to embed web pages? Or is it likely that the IFRAME will be well-supported into the future (long after I am old and grey, and past the useful life of the application I maintain)?

推荐答案

IFRAME 元素即将推出的 HTML5 的一部分标准.此外,HTML5 是由主要浏览器供应商(Mozilla、Opera、Safari、IE)开发的,这基本上保证了在可预见的未来我们将拥有 IFRAME 元素.其中一些已经支持某些 HTML5 元素,例如 AUDIO 和 VIDEO 以及一些新的 JavaScript API.

The IFRAME element is part of the upcoming HTML5 standard. Also, HTML5 is developed by the major browser vendors out there (Mozilla, Opera, Safari, IE), that basically makes a guarantee that we will have an IFRAME element in the foreseeable future. Some of them have support for some HTML5 elements already, like AUDIO and VIDEO and some new JavaScript APIs.

OBJECT 元素在草稿,但那是因为 IFRAME 和 OBJECT 将有不同的目的.IFRAMES 主要用于沙盒 Web 应用程序.

It's also true that the OBJECT element is in the draft, but that's because IFRAME and OBJECT will have different purposes. IFRAMES are mainly designed for sandboxing web applications.

所以,我的建议是使用 IFRAME 而不是 OBJECT.

So, my advise is to use IFRAME instead of OBJECT.

这篇关于使用 iframe 或 Object 标签将网页嵌入到另一个网页中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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