If i was to visit the source of my iframe, I notice that it has a value "srt" , I can access this variable by simply typing "srt" When in the iframes Source. However when it is an "iframe" typing "srt" no longer works since the variable is nested within the iframe.
How can i store the value of a variable that is in an iframe, To a variable that is not In the iframe, to access this value Outside.
You can use the frames collection by index or by the frame's name. Each element in the collection is the
window
object for that frame, which is where global variables are stored.Or you can get the iframe element and use contentWindow to retrieve the iframe's window object
Also remember that you can't access a frame that is not in the same domain.
Assuming the iframe has an id
frame
, from the parent:Or the other way round, from within the iframe: