5

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

james.garriss
  • 12,959
  • 7
  • 83
  • 96
Alex
  • 66,732
  • 177
  • 439
  • 641

2 Answers2

6

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

Piskvor left the building
  • 91,498
  • 46
  • 177
  • 222
4

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)

james.garriss
  • 12,959
  • 7
  • 83
  • 96