如何在帧之间保存Javascript变量? [英] How to save Javascript variable between frames?

查看:91
本文介绍了如何在帧之间保存Javascript变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两个不同的框架(frame1和frame2)中有一个名为myvar的javascript变量。我需要在frame1中取myvar并将其设置为frame2中myvar的值。如何在不使用外部脚本的情况下执行此操作?

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?

推荐答案

如果变量位于父级中,请使用:

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

这篇关于如何在帧之间保存Javascript变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆