I want to access the iframe my page is in and resize it. By the way I'm doing it in javascript.
It's something like parent and height or offsetHeight.
<iframe src="mypage.asp" height="400" width="400" ></iframe>
And in mypage.asp I do sth similar like this:
var h = // new height;
parent.height = h;
But it ain't all right? Somebody else who knows more?
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.
Create HTML Create a <div> element with an id "wrap". Place an <iframe> element with an id "scaled-frame" inside the <div>. Add the src attribute with the content you want to display.
Try this if you want to resize the iframe from within the page that is loaded in your iframe. It seems to work locally at least:
function doIt() {
var elem = window.parent.document.getElementById('myIframe'); // the id of your iframe of course
elem.style.height = '40em';
}
I assume both the page and your iframe are yours and have the same "origin".
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