好吧,所以我想iFrame一个网页。我不知道为什么,但它不会留在我的页面(它弹出并进入主页面)。我正在使用的代码是:使用任何网页语言,如何在页面中保留一个iframe?
<iframe>http://mywebsite.com</iframe>
如何将其保存在我的网站中?
好吧,所以我想iFrame一个网页。我不知道为什么,但它不会留在我的页面(它弹出并进入主页面)。我正在使用的代码是:使用任何网页语言,如何在页面中保留一个iframe?
<iframe>http://mywebsite.com</iframe>
如何将其保存在我的网站中?
您需要使用src
属性。放在一个iframe的标签内
<iframe src="http://mywebsite.com"></iframe>
HTML /文本内容被视为“回退”的内容,只显示了,如果浏览器不支援iframe。详细信息请参阅MDN documentation。
<iframe src="http://mywebsite.com">
This sentence only shows up if the browser doesn't support iframes!
</iframe>
因此,你创建一个没有指向任何页面,其中的src
性质(所以它仍然是空白)的iframe,并有文字“http://mywebsite.com
”作为后备文字出现在浏览器中,唐”不支持iframe。
编辑:
如果不控制的网站,它有可能是诬陷网站有一些逻辑,说是这样的:
// if we are not the highest frame, someone is try to frame this site
if(window.parent != window)
// redirect the framing parent site to our site
window.parent.location.href = 'http://iframedsite.com';
这个逻辑检测,如果该网站是为由其他人嵌入(例如,您自己的站点)并重定向父框架。您可以通过简单构建IANA的网站https://www.iana.org/
(或者仅仅是http://www.example.com
)来确认这是否是问题,在框架框架内播放时不会发生父框架重定向。
试试这个:
<iframe src="http://mywebsite.com"></iframe>
好的,我试了你的方式,它仍然弹出。 – Frank 2012-07-26 05:40:43
“弹出”是什么意思?它在新窗口中打开?或整个页面重定向到iframe的来源? – apsillers 2012-07-26 05:48:26
不,但不是在iFrame中,它会转到主窗口。所以,而不是http://mywebsite.com,它是http://iFramedWebsite.com – Frank 2012-07-26 05:50:16