简体   繁体   English

如何在帧之间保存Javascript变量?

[英]How to save Javascript variable between frames?

I have a javascript variable called "myvar" in two different frames (frame1 and frame2). 我在两个不同的帧(frame1和frame2)中有一个名为“myvar”的javascript变量。 I need to take the myvar in frame1 and set it as the value of the myvar in frame2. 我需要在frame1中取myvar并将其设置为frame2中myvar的值。 How do I do this without an external script? 没有外部脚本我该怎么做?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM