I try to listen from inside of iframe to changes of iframe width/height with:
$(window).resize(function(){
alert('1 on inside iframe');
});
or:
$(window.parent).find('iframe').resize(function(){
alert('2 on inside iframe');
});
but nothing happens when iframe size changes. (I need a cross-browser solution: IE7, Chrome, Firefox, Safari.)
Answer: Use the contentWindow Property You can use the JavaScript contentWindow property to make an iFrame automatically adjust its height according to the contents inside it, so that no vertical scrollbar will appear.
Edit the width attribute. You should see the attribute "width=" after the URL in the iframe tag. Edit the width in pixels in quotations (" ") after the "width=" attribute. For example, if you want the width to be 300 pixels, you would enter "width="300px"" after the URL in the tag.
$(body).resize(function(){
alert('on inside iframe');
});
Edit :
in html
<body onresize="myFunction()">
You need to call the resize()
handler from the parent
document on the iframe
:
$('iframe').resize(function() {} );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With