1

I have sidebar toggle event. When I clicked inside the iframe, the sidebar doesn't close. The Iframe is in the inside of div #maincontent. But when iframe has an src="" ( src="pr.php" ) the close event not worked. How I can close the sidebar when I clicked in iframe that does have any of src=" " ?

Here's my fiddle

http://jsfiddle.net/8nhmU/13/

<div class="framecontentLeft">
<div class="innertube">

</div>
</div>

<div id="framecontentTop">
<div class="sidebar-toggle"></div>
<div class="innertube">

</div>
</div>

<div id="maincontent">
<div class="innertube">

<iframe name="contents" src="http://stackoverflow.com" id="iframe1" frameborder="0" style="moz-overflow:hidden;moz-overflow-x:hidden;moz-overflow-y:hidden;height:100%;width:100%;position:absolute;top:0px;left:0px;right:0px;bottom:0px" height="100%" width="100%"> </iframe>

</div>
</div>

Part of the Script

var iframeDoc = $('#iframe1').contents().get(0);
$(iframeDoc).bind('click', function( event ) {
if(!sidebarStatus)
    {
               $('.sidebar-toggle').click();
    }
});
user3097736
  • 284
  • 5
  • 23

1 Answers1

0

Try this. Used the body of Iframe. This should work !

$('#iframe1').load(function(){
  $(this).contents().find("body").on('click', function(event) {     
  if(!sidebarStatus)
        {
                   $('.sidebar-toggle').click();
        } });
});
surname
  • 163
  • 1
  • 1
  • 17