|
-
Mar 25th, 2007, 11:07 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] ie7 window.onresize
I had to write a work around for the code i found here:
http://www.webmasterworld.com/forum91/3429.htm
Code:
function resize(){
var frame = document.getElementById("frame1");
var htmlheight = document.body.parentNode.scrollHeight;
var windowheight = window.innerHeight;
if ( htmlheight < windowheight )
{
document.body.style.height = windowheight + "px";
frame.style.height = windowheight + "px";
}
else {
document.body.style.height = htmlheight + "px";
frame.style.height = htmlheight + "px";
}
}
The code works in firefox and I just thought some minor tweaks and it would work in ie7. Well, apparently in ie7 the resize event gets called when each of the line in the if statement get executed. So, ie7 goes into a nice loop.
I wrote a workaround below that seems to work. However, anybody know a more graceful besides using a timer?
Code:
<script type="text/javascript">
//<![CDATA[
function wait() {
if (document.getElementById("wait").value == "f") {
document.getElementById("wait").value = "t";
resize();
}
else {
self.setTimeout("change()",500);
}
}
function change() {
document.getElementById("wait").value = "f";
}
function resize(){
//http://www.webmasterworld.com/forum91/3429.htm
var frame = document.getElementById("gets"); /*frame is a div*/
var htmlheight = document.body.parentNode.scrollHeight; /*window.innerHeight; for FF*/
var windowheight = document.documentElement.clientHeight;
//div#main, div#dpspane, div#main_tabs, div#case_tabs,div#footer
if ( htmlheight < windowheight )
{
document.body.style.height = windowheight + "px";
document.getElementById("gets").style.height = windowheight + "px";
//document.getElementById("main").style.height = windowheight + "px";
} //end if
else {
document.body.style.height = windowheight + "px";
document.getElementById("gets").style.height = windowheight + "px";
//document.getElementById("main").style.height = windowheight + "px";
}
}
window.onresize = wait;
//]]>
</script>
-
Mar 26th, 2007, 03:55 AM
#2
Re: ie7 window.onresize
Grab this.
Use it like this:
Code:
function resize()
{
removeEHandler(window, 'resize', arguments.callee);
var frame = document.getElementById("frame1");
var htmlheight = document.body.parentNode.scrollHeight;
var windowheight = window.innerHeight;
if ( htmlheight < windowheight )
{
document.body.style.height = windowheight + "px";
frame.style.height = windowheight + "px";
}
else {
document.body.style.height = htmlheight + "px";
frame.style.height = htmlheight + "px";
}
addEHandler(window, 'resize', arguments.callee);
}
addEHandler(window, 'resize', resize);
-
Mar 26th, 2007, 12:25 PM
#3
Thread Starter
Hyperactive Member
Re: ie7 window.onresize
That worked beautifully in ie6/7.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|