Alex
Alex

Reputation: 67698

Is it possible to emulate an iframe?

is there a way to get the contents of a page, for example http://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 :)

Upvotes: 6

Views: 4615

Answers (2)

james.garriss
james.garriss

Reputation: 13406

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)

Upvotes: 4

Piskvor left the building
Piskvor left the building

Reputation: 92772

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

Upvotes: 6

Related Questions