0

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?

Jaqen H'ghar
  • 16,186
  • 8
  • 49
  • 52
Daniel Smith
  • 1,626
  • 3
  • 29
  • 59
  • Nothing is simple when dealing with iFrames. Do anything to avoid them at all. If you want to pass a variable into the frame, you could add them as a parameter of your iFrame url. Maybe this gives you an idea: http://stackoverflow.com/questions/251420/invoking-javascript-code-in-an-iframe-from-the-parent-page?rq=1 – Marcel Dieterle Nov 30 '16 at 19:57

1 Answers1

0

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

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

See Plunker example

Jaqen H'ghar
  • 16,186
  • 8
  • 49
  • 52