开发者

Is it possible to emulate an iframe?

is there a way to get the contents of a page, for example 开发者_如何学Pythonhttp://google.com, and insert it in the current document, but in the way that the iframe does, I mean... with styles, scripts and everything that page has ?

And make so the styles and scripts don't affect the current document :)


No, not really: you can get the contents of a page through various AJAX-y techniques, but when you insert them into your page, they'll always have your page's CSS applied to them. You could make some sort of "CSS reset" for the "not-iframe" element, but this will be messy.

Essentially, if you want the separation provided by frames, you need to use frames/iframes (unfortunately, this applies to all content, so CSS will be separated, but also JS, with all the related cross-domain brouhaha).


Absolutely. You can use the object element, like so:

<!DOCTYPE html>
<html>
    <body>
        <object data="http://www.google.com" type="text/html"></object>
    <body>
</html>

(Works with IE8, Chrome 10, FF 4, and Safari 5 on Win XP)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜