简体   繁体   中英

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. How can I change the isredirect value from true to false from within the iframe? 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. To make sure the variable already exists in the parent, you can do this:

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

应该这样做:

parent.isRedirect = true;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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