471,310 Members | 1,285 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

problem with iframe resizing 2

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 :
displayFrm.contentWindow.document;

objToResize = (displayFrm.style) ? displayFrm.style : 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"
onload="resize();">
</iframe>
Jul 23 '05 #1
1 2235
Hello

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)?

1. ONLOAD EVENT

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
documents.

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.

3. FURTHER READING

A useful page on IFRAMES is:-

http://www.dyn-web.com/dhtml/iframes/

A similar post on another site:-

http://www.ozoneasylum.com/9671&latestPost=true

Julian
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Catherine Lynn Smith | last post: by
4 posts views Thread by khothikhe | last post: by
5 posts views Thread by Paul Fi | last post: by
2 posts views Thread by paul | last post: by
1 post views Thread by Z1P2 | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.