By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,372 Members | 1,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,372 IT Pros & Developers. It's quick & easy.

problem with iframe resizing 2

P: n/a
Can someone help me here because this is really killing me!

the problem is, i have this javascript code in my aspx page that i want it
to work on almost all browsers, especially opera and safari :

function resize(){
displayFrm = document.getElementById("ifrmDisplay");

innerDoc = (displayFrame.contentDocument) ?displayFrm.contentDocument :

objToResize = ( ? : displayFrm;

objToResize.height = innerDoc.body.scrollHeight;

the code above gets called every time a new page is loaded inside the iframe
(ifrmDisplay) what its doing is resizing the iframe so it can have the same
size as the page inside it, so i can eliminate the need for vertical
scroller for the iframe, i assumed that it works on opera and IE at the same
time, when i tried it out, it worked on IE but not on opera. after lot of
time in researching how i can get workaround this issue with opera, that is
the best possible solution i have and yet it doesnt work. so i gave up and
asking you if you can help me out here , coz this is jst driving me crazy!

the problem is im not a javascript expert, to be honest i jst started doing
javascripts about two days ago, that is why im in need for help

by the way, here is inner html for the iframe if its any use

<iframe id="ifrmDisplay" style="Z-INDEX: 99; LEFT: 187px; WIDTH: 567px;
POSITION: absolute; TOP: 136px; HEIGHT: 408px" src="" scrolling="no"
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a

Some quick thoughts.

You may need to be clearer about what exactly is not working.

Is it that:-

(1) the IFRAME onload event (and resize function) is not firing at
all, or

(2) that the resize function is not working as expected (i.e. the
height is not the desired height)?


I think (I could be wrong) that Opera does not support the onload
event on the IFRAME element.

It does however I think support the "readyState" property on

So in Opera, your only way may be to include either:-

(a) Some script within the web page to be loaded in the IFRAME, that
calls the parent method:-

<BODY onload="window.parent.resize('IFRAMEID')">

(b) Monitor the document readyState from the parent using a
setInterval process.

I.e. if (myIFrame.contentWindow.document.readyState=="comp lete"){resize();}

2. IFRAME not resizing properly

The scrollHeight value may not be reliable.

Browsers may vary as to whether they take into account margins around
HTML and BODY elements. So you may need to experiment a little here.

Also, you need to take into account the borders and margins of the
IFRAME element itself.


A useful page on IFRAMES is:-

A similar post on another site:-

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.