FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free 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.
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
Related topics
PHP Chat (now rather good) how to design socket chat?
Site Nav Suggestions...
Tech Support
FIRE FOX 4.0 beta 7
Gif, Flash or html5 animations for Banners
How Java is different than Javascript !!
PB PHP, Iframe and Javascript
AJAX tutorial [2nd part now updated]
Can you target a <div> like a frame?
JAVASCRIPT FUNCTION- ONCLICK HELP!!
JavaScript confirm() problem
HTML help needed
Is it possible to change the bgcolor of <iframe> in IE
problem adding variables in javascript
Reply to topic    Frihost Forum Index -> Webmaster and Internet -> Design Tips

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