开发者

Inline iframe does not get loaded

开发者 https://www.devze.com 2023-03-24 13:23 出处:网络
If I create an HTML file with an inline iframe like this <body> <iframe> <html> <body开发者_如何学运维>

If I create an HTML file with an inline iframe like this

<body>
    <iframe>
        <html>
            <body开发者_如何学运维>
                Hello World!!
            </body>
        </html>
    </iframe>
</body>

and open the page in browser, nothing gets printed. But if I specify a <iframe src="test.php"> attribute, with test.php having the same code,

<html>
    <body>
        Hello World!!
    </body>
</html> 

as the inline iframe, I get "hello world" printed... why is that? Is an inline iframe not legal?


That's how iframes work. The src attribute specifies the content. If your browser doesn't support iframes then the inner HTML will be rendered. The usual pattern is:

<iframe src="contents.html">
Your browser doesn't support iframes!
</iframe>

The reason you don't see anything rendered is because your browser supports iframes.

0

精彩评论

暂无评论...
验证码 换一张
取 消