How to save Javascript variable between frames?

前端 未结 1 1841
傲寒
傲寒 2021-01-18 10:18

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.

1条回答
  •  无人及你
    2021-01-18 11:08

    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
    

    0 讨论(0)
提交回复
热议问题