Welcome to WebmasterWorld Guest from 184.108.40.206 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
I am trying to alter the style property of an object (lets call it link) within an iFrame (lets call it daFrame) of a page. The code that I am using:
document .getElementById( 'daFrame' ). document .getElementById( 'link' ).style.backgroundColor="#000";
Well, all you have to do is call the iframe like you would any other frame:
The iframe needs a name though ..
It's part of the window.frames collection because it's a kind of frame AND it's also a part of the document tree because it's an element.
with x being 0 if there are no other iframes in the document.
also the syntax you had before should be ok, I wonder why it's not working. The problem may be the id "link".
Try something else. If it still doesn't work, try it using the frames collection as above and then, if it still doesn't work, the problem lies elsewhere. DrDoc
Also, it's not necessary to use "backgroundColor" .. you can use just "background" BlobFisk
Thanks for all your suggestions. As per ricfinks suggestion I used the window.frames syntax and this is working perfectly now:
I'm not sure why trying to get at it using getElementById didn't work, as (like ricfink) I thought that an iFrame lived both in the Frames array and the Id array.
background and backgroundColor work sine (in IE) - does anyone know which is the W3C standard for this? DrDoc
They are both W3C standard (or JS standard if you want). It's just that "background" is more widely supported.