Hello i am trying to resize the iframe based on its content but its not working may be becuase of the cross domain here is the code i am using <script language="javascript" type="text/javascript"> function resizeIframe(obj) { obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px'; } </script> <iframe src="http://other_domain_name/get?v=07armilCx5A" frameborder="0" scrolling="no" id="iframe" width="100%" height="300px" onload="javascript:resizeIframe(this);"></iframe> Code (JavaScript): Please help me how this will be resolved to grab a page in iframe from other domain
You don't -- PRECISELY because being able to do so violates the security policy. Though as I keep asking people, when did we get to 1997... after all that's the last time anyone had any business using an iframe, or frames for that matter. You know, it was called HTML 4 STRICT?
2 Problems: First, the onload event handler simply isn't firing! After a bit of googling it seems it will only fire if the src attribute is set and it actually loads some page (Kind of makes sense, now that I am writing about it ) Second, for the security problem.. just have a look at the code: <body> <iframe class="stumble-frame" src="http://fallinprices.com" onload="resizeIframe(this)"></iframe> <script language="javascript" type="text/javascript"> function resizeIframe(obj) { alert(1); obj.style.height =document.body.scrollHeight + 'px'; } </script> </body> Code (JavaScript):