Opening Javascript Frames

In javascript, how do I get the handle of the frame I'm set to based on the element in that frame?

function myFunction(elementInFrame){
   // here I want to get a handle on the frame that elementInFrame lives in
}

      

+1


source to share


2 answers


elementInFrame.document.defaultView for non-IE browsers.



(This is not really a standard part of the DOM; DOM Level 2 Views says the property exists but does not explicitly indicate that it points to a "window", since the DOM standard currently knows nothing about the window object.)

+3


source


In IE you can do elementInFrame.document.parentWindow

Doesn't work in Firefox unfortunately.



Edit: if you are using frames then in FF you can do it a long way ... loop through all the frames until you find the element you want.

+2


source







All Articles