Getting HTML source code from IFrame

S

syshex

Hi everyone !

I'm really new to javascript, and am possibly aiming quite high
already, but still I feel I just satisfy my curiosity and ask you all
this question.

I've got this really really simple page which has an Iframe with
id="AAA" and a div section with id="BBB" . I've also got a link that
is points to void but onclick action fires a function.

What this function should do is make the Iframe load a specific page.
For that I use this code :

function firenow()
{
top.document.getElementById("AAA").src = "http://www.google.com/"
;
}

This is working fine.

Now the IFrame has an onload calling another function .... and what
this function should do it get all the source HTML (<html> <head>
,...... </head> .... </html> ) of the page being displayed on the
Iframe AAA and place that source code in the DIV BBB or inside a
variable if you would like.

Is this at all possible ?
Can anyone provide a really simple sample of how to do this ?
thanks a lot for your help

sh
 
M

Matt Kruse

top.document.getElementById("AAA").src = "http://www.google.com/"
Now the IFrame has an onload calling another function .... and what
this function should do it get all the source HTML (<html> <head>
,...... </head> .... </html> ) of the page being displayed on the
Iframe AAA and place that source code in the DIV BBB or inside a
variable if you would like.
Is this at all possible ?

No.
Security restrictions in browsers make this impossible unless both the
parent document and iframe document are in the same domain.
Otherwise, bad things would be possible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,585
Members
45,081
Latest member
AnyaMerry

Latest Threads

Top