Ghooti Farangi
Ghooti Farangi

Reputation: 20156

Access to a variable in an iframe by jquery selector

I have following:

<iframe id="test">
   <script>
     variable='hi';
   </script>
</iframe>

I need to know how can I access to a variable by jquery selector from the top window like this $("#test").variable ?

Upvotes: 6

Views: 7863

Answers (1)

Ankur
Ankur

Reputation: 33637

You can try :

$("#test")[0].contentWindow.variable;

Upvotes: 15

Related Questions