Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Setting onload and onresize events to window problem

Reply
Thread Tools

Setting onload and onresize events to window problem

 
 
johkar
Guest
Posts: n/a
 
      10-29-2006
The below script executes fine and sets both divs to equal height,
however if I try adding onresize also IE has a major problem and
freezes up. What am I missing here? Note I would like to be able to
call this script by calling it from the body tag or from an inline
script (currently commented out below).

John

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style type="text/css">
div {
border:1px solid #003366;
padding:7px;
width:250px;
float:left;
margin-left:15px;
}
</style>
<script type="text/javascript">
function setDivHeights(id1,id2,id3){
if(document.getElementById){
var div1 =
(document.getElementById(id1))?document.getElement ById(id1):false;
var div2 =
(document.getElementById(id2))?document.getElement ById(id2):false;
var div3 =
(document.getElementById(id3))?document.getElement ById(id3):false;
if(div1 && div2){
var max = div1.offsetHeight;
if(div2.offsetHeight > max)
max = div2.offsetHeight;
if(div3 && (div3.offsetHeight > max))
max = div3.offsetHeight;

document.getElementById(id1).style.height = max + "px";
document.getElementById(id2).style.height = max + "px";
if(div3)
document.getElementById(id3).style.height = max + "px";
}
}
}
//window.onload=function(){setDivHeights('div1','div 2');}

</script>
</head>

<body onload="setDivHeights('div1','div2')">
<div id="div1">
<p>Some Text Some Text Some Text Some Text Some Text Some Text Some
Text Some Text Some</p>
</div>
<div id="div2">
<p>Some Text Some Text Some Text Some Text Some Text Some Text Some
Text Some Text Some Text Some Text Some Text Some Text Some Text Some
Text Some Text</p>
</div>
</body>
</html>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
window.onresize slow (firefox) yb Javascript 1 03-19-2007 07:47 AM
Why onResize fires 3 times when I re-size the window? df Javascript 14 05-23-2006 12:53 PM
window.onresize problem in IE6 David Gravereaux Javascript 8 02-23-2006 09:23 PM
body onresize vs window.onresize Tony Javascript 2 11-29-2005 09:10 PM
window.onload and body.onload differences David Otton Javascript 2 11-04-2004 04:34 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57