Search code examples
javascriptjqueryiframereloaddetect

Detect when <iframe> parent element changes from hidden to shown


How can I detect when an iframe is shown from hidden element ?

HTML :

<div style="display:none">
 <iframe></iframe>
</div>

So when I show the <div> by jQuery via $('div').show();, How can I detect and reload this iframe ?

PS : Detection should happen inside an iframe file.

NOT : $('div').show(function(){//do something}); or this ? (NOW I NOT SURE)


Solution

  • $('div').show("slow",function(){
      var iframe = $(this).find("iframe");
       iframe.attr('src', "SOME_URL");
    });