简体   繁体   English

Javascript从iframe更改父项中的文本

[英]Javascript change text in parent from iframe

I have the following variable in a script in a webpage : 我在网页的脚本中有以下变量:

var isRedirect = true;

I also have an iframe. 我也有一个iframe。 How can I change the isredirect value from true to false from within the iframe? 如何在iframe中将isredirect值从true更改为false? var isRedirect = true; is in the parent page. 在父页面中。

parent.isRedirect = false;

The tricky part is to have the correct synchronization between the parent and the iframe. 棘手的部分是在父级和iframe之间进行正确的同步。 To make sure the variable already exists in the parent, you can do this: 要确保变量已存在于父变量中,可以执行以下操作:

if (parent.isRedirect) {parent.isRedirect = false;}

应该这样做:

parent.isRedirect = true;

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

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