Nov 19th, 2012
// 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>
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:
(function($){ parent.$(document).ready(function() { if (window.parent) { parent.$(parent.document).find("#user-tab a").eq(1).trigger('click'); } }); }(jQuery))