Balakumar
Balakumar

Reputation: 131

How to use the nested iframe in html?

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

    <!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.

Upvotes: 8

Views: 45343

Answers (4)

Charlie
Charlie

Reputation: 41

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

The link to access this page should have ?interframe=true at the end of it.
e.g. http://www.example.com/test.html?interframe=true
You shouldn't add ?interframe=true to the ends of http://www.w3schools.com and http://www.bing.com though.

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

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

I hope this helps.

Upvotes: 4

Martin Ivanovich
Martin Ivanovich

Reputation: 164

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.

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

MainPage.html

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

Page1.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.

Upvotes: 2

andri
andri

Reputation: 1021

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>

Upvotes: 1

Quentin
Quentin

Reputation: 943097

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

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

Upvotes: 8

Related Questions