I have a javascript variable called "myvar" in two different frames (frame1 and frame2). I need to take the myvar in frame1 and set it as the value of the myvar in frame2. How do I do this without an external script?
1 Answer
If the variable is in the parent, use:
window.parent.varName
If it's in another frame, go through the parent, then to the frame:
window.parent.frameName.varName
5 Comments
parap
How do you change the varName? could you use an example using "myvar" as both variables?
walmik
window.parent.frame1.myvar = window.parent.frame2.myvar
Julian Hille
This only works for same scheme domains:port. As of same domain policy. Just to be curious.
David Houde
are both frames on the same domain? sub domains on the same TLD?
parap
Sorry, my bad. I needed to pass two variables. I only passed one. It's working now. Thanks.
window.parent?