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

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

问题描述

在一个基于网络的系统中,我维护最近上线的工作,它在主网页中嵌入了第二个网页。 (实际上,主网页包含菜单和标题,并且主应用程序页面在对象中)



例如

 < object id =contentareastandby =正在加载数据,请稍等...
title =正在加载数据,请稍候...宽度=100%height =53%
type =text / htmldata =MainPage.aspx>< / object>

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



我被告知赞成在IFRAME上使用object标签的原因是IFRAME已被弃用,所以不能依赖未来版本的浏览器。这是真的吗?是否最好在iframe上使用Object标签来嵌入网页?或者IFRAME可能会在未来得到很好的支持(很久以后我老了,灰色,并且超过了我维护的应用程序的使用寿命)? >解决方案

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



OBJECT元素在草稿中,但那是因为IFRAME和OBJECT会有不同的目的。 IFRAMES主要用于沙盒网络应用程序。



因此,我的建议是使用IFRAME而不是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)

For example

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

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.

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)?

解决方案

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.

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.

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

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

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