简体   繁体   中英

Passing javascript variable from parent to iframe

So I have a variable in my page body like so:

<script>
   var myClick = false;
</script>

And a jquery ui dialog with iframe content. Now I want to check the variable on jquery ui dialog like -

<script>
   if(myClick == true){
      // code somthing
   }
</script>

What is the simplest way to do that?

If the iframe is on the same domain you can use window.parent.myClick

if (window.parent.myClick === true) {
  // code somthing
}

See Plunker example

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