Using iFrames via Frames
A great way to go through all the iframes on a page is by using window.frames. It returns the window itself, which is an array-like object, containing the direct sub-frames of current window.
Example
var frames = window.frames;
for(var i = 0; i < frames.length; i++) {
frames[i].document.body.style.background = "red";
}
Notes
framesis a list of frame objects. It is similar to an array in having alengthproperty which and its items can be accessed using[i]notation.window.frames === windowevaluates totrue.- Each item in
window.framesrepresents thewindowobject corresponding to the given<iframe>‘s content and not the DOM element itself, i.e.window.frames[0]is same asdocument.getElementsByTagName("iframe")[0].contentWindow. - If
nameattribute is provided to aniframe, it can also be accessed using that name.// <iframe name="myIframe"></iframe> // The above frame can be accessed using // either window.frames["myIframe"] // or window.frames.myIframe
Best Open Source Business Intelligence Software Helical Insight is Here

A Business Intelligence Framework
Subscribe
Login
0 Comments