Setting onload and onresize events to window problem

J

johkar

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.getElementById(id1):false;
var div2 =
(document.getElementById(id2))?document.getElementById(id2):false;
var div3 =
(document.getElementById(id3))?document.getElementById(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','div2');}

</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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top