Html 如何在html中使用嵌套的iframe?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15018738/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:48:32  来源:igfitidea点击:

How to use the nested iframe in html?

html

提问by Balakumar

I am trying like this.But frame1 is visible. I can't show the frame2. The code is below,

我正在尝试这样。但是 frame1 是可见的。我无法显示frame2。代码如下,

    <!DOCTYPE html>
<html>
<body>

<iframe src="http://www.w3schools.com" width="1000" height="1000" id="frame1" name="frame1">
  <iframe width="200" height="200" src="http://www.bing.com" id="frame2" name="frame2">
  </iframe></iframe></body></html>

Can any one please help me.

谁能帮帮我吗。

回答by Quentin

The child elements of an iframe are alternative contentfor use if frames are disabled or not supported.

如果框架被禁用或不受支持,iframe 的子元素是可供使用的替代内容

Either make the child frame a sibling or move it to the document you load into the outside frame.

要么使子框架成为同级框架,要么将其移动到您加载到外部框架中的文档中。

回答by Charlie

If you want an iframe inside of and iframe you should do the following:

如果你想要一个 iframe 和 iframe,你应该执行以下操作:

The link to access this page should have ?interframe=trueat the end of it.
e.g. http://www.example.com/test.html?interframe=true
You shouldn'tadd ?interframe=trueto the ends of http://www.w3schools.comand http://www.bing.comthough.

访问此页面的链接应?interframe=true在其末尾。
例如,http://www.example.com/test.html?interframe=true
不应该添加?interframe=truehttp://www.w3schools.comand的末尾http://www.bing.com

To make it clear:
Let's say your homepage is http://www.example.comAnd the page that you need help with is http://www.example.com/test

明确地
说:假设您的主页是http://www.example.com而您需要帮助的页面是http://www.example.com/test

The <a>tag in http://www.example.comthat brings you to http://www.example.com/test.htmlshould be <a href="http://www.example.com/test.html?interframe=true">example text</a>

<a>在标签http://www.example.com,带你到http://www.example.com/test.html<a href="http://www.example.com/test.html?interframe=true">example text</a>

I hope this helps.

我希望这有帮助。

回答by Martin Ivanovich

You can stack it up. But for nesting, you need to edit it.

你可以把它叠起来。但是对于嵌套,您需要对其进行编辑。

Main page has iframe code pointing to page1. Page 1 has iframe code pointing to page2.

主页具有指向 page1 的 iframe 代码。第 1 页具有指向第 2 页的 iframe 代码。

Don't nest them in one page. If you can't edit page 1 then stack them up.

不要将它们嵌套在一页中。如果您无法编辑第 1 页,则将它们堆叠起来。

MainPage.html

主页.html

<DOCTYPE html><html><body>
<iframe src="page1.html" width="1000" height="1000" id="frame1" name="frame1"></iframe>
</body></html>

Page1.html

页面1.html

<!DOCTYPE html><html><body>
<iframe width="200" height="200" src="page2.html" id="frame2" name="frame2"></iframe>
</body></html>

For stacking, see @Andri answer.

有关堆叠,请参阅@Andri 答案。

回答by andri

try change your markup into the following :

尝试将您的标记更改为以下内容:

<!DOCTYPE html>
<html>
    <body>
        <iframe src="http://www.w3schools.com" width="1000" height="1000" id="frame1" name="frame1">
        </iframe>
        <iframe width="200" height="200" src="http://www.bing.com" id="frame2" name="frame2">
        </iframe>
    </body>
</html>