jQuery iframe

// manipulate contents of iframe and its properties***
 
// iframe must be in same domain*
// notice the use of $(#iframe).contents().find*
 
(function($){
    $(document).ready(function() {
        $('#iframe_vbforum').load(function(){
            // to control the iframe itself
            $('#iframe_vbforum').attr('scrolling', 'yes');
            // to target things inside the iframe 
            $('#iframe_vbforum').contents().find('#header-left img').css({'max-width':'100%','height':'auto'});
        });
    });
}(jQuery))

To avoid waiting for the iframe to be completely loaded:

1) put this as the last piece of code in the iframe:
<script type="text/javascript">
//<![CDATA[
parent.$(document).ready(function(){
  parent.VBIFrameLoaded();
});
//]]>
</script>
2) put js that you want to run when iframe is ready into a function called VBIFrameLoaded()
To trigger a click outside an iframe using js in the iframe, first include the jquery library even if the parent page already loaded it. Example of full code:
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
(function($){
  parent.$(document).ready(function() {
    if (window.parent) {
      parent.$(parent.document).find("#user-tab a").eq(1).trigger('click');
    }
  });
}(jQuery))

Article Type

General