FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Problems with document.innerHTML and iframe (javascript)

 


trefen
Hello

I got a problem... Sad I must get the source of a page in an iframe. I have tried manny things, but I only get "Undefined" or what's between the <iframe> and </iframe> tags... Can somone tell me how to do it?

Thanks!
Panrac
You must copy url of the src attribute, then open it and ones again view the source.
There is also extension for Firefox which will enable You to do that automatically, called HTML validator.
***
Sorry, now I've noticed how stupid was my answer.


Last edited by Panrac on Sun Apr 09, 2006 9:23 pm; edited 1 time in total
Kaneda
Have you made sure that the document in the <iframe> has actually loaded, before you try to access it?

Should be something like (the most standard way):

Code:
var html = document.getElementById("myIframe").document.body.innerHTML;


or:

Code:
var html = frames["myIframe"].document.body.innerHTML;


But note that the latter requires the frame to have a name attribute (which is not allowed in XHTML), and it will not work reliably with iframes generated by DOM manipulation in javascript (i.e., the iframe should be part of the static HTML code).
trefen
Thanks! It works! Very Happy Very Happy Very Happy Very Happy Very Happy
Reply to topic    Frihost Forum Index -> Webmaster and Internet -> Design Tips

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.