PDA

View Full Version : Changing the innerHTML of a div inside an iframe.



lordjeremiahs
11-24-2007, 02:31 PM
how to do it by javascript?
i tried:
window.frames[framename].document.getElementByID(divname).innerHTML

is something wrong with that?

Twey
11-24-2007, 02:34 PM
It's getElementById(), case sensitive. The page inside the frame must be on the same domain for security reasons. innerHTML is non-standard and standard DOM methods should be used instead.

jscheuer1
11-24-2007, 02:50 PM
Also, the document within the iframe is referred to differently by various browsers. Since this only works on pages on the same domain, one would assume that if you have editing privileges for the top document, you have them for the one in the iframe. Put your script on it. You can then call the script from the top page in a much more consistent cross browser fashion than you can perform document actions from the top page upon the en-framed page.

lordjeremiahs
11-25-2007, 01:31 AM
uhh.. sori but i just cant understand what your saying because im too noob in javascript. but, is there a way to access a div inside an iframe ?

jscheuer1
11-25-2007, 03:35 PM
uhh.. sori but i just cant understand what your saying because im too noob in javascript. but, is there a way to access a div inside an iframe ?

That being the case, do you at least understand what being on the same domain means? If not, you need to. If you do, but the pages are not, it cannot be done using javascript alone and is probably beyond what is permitted in these forums, unless you own both domains, in which case something may be able to be worked out.

A domain, by the way is, for example:

www.somename.com

The pages have to be on the same domain.