Click to See Complete Forum and Search --> : Positioning a form crashes IE5.5


sametch
05-13-2003, 12:52 AM
I have written a script which centers web page elements by changing the position of a style element according to the width of the page.

The script works fine until I put a form inside the style element on the page. Then it crashes IE5.5 and AOL 7 (kills dead!).

Is there something wrong with doing this. My HTML code and Script follows:

**Script**

function CentreWebDesign(DesignWidth)
{
var LeftStart=0;
var PageSize=0;
if (document.body.clientWidth != null)
{
PageSize=document.body.clientWidth;
}
else
{
if (window.innerWidth != null)
{
PageSize=document.innerWidth;
}
}
if (PageSize > DesignWidth)
{
LeftStart=Math.round((PageSize - DesignWidth)/2);
}
document.getElementById('container').style.left = LeftStart;
}

**End Script**

**HTML**

<html>
<head>
<title>title</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript" src="c.js"></script>
<link href="content.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
#container{position: absolute; top: 15px; left: 0px}
-->
</style>
</head>
<body onLoad="CentreWebDesign(740); MM_preloadImages('images/faq-o.gif','images/contacts-o.gif','images/clients-o.gif','images/features-o.gif','images/services-o.gif','images/about-o.gif','images/home-o.gif')" onResize="CentreWebDesign(740)">
<div id="container">
<div class="heading">how to contact us</div>
<div class="content">
<form name="form1" method="post" action="thanks.php">
<table width="670" border="0" align="center" cellpadding="0" cellspacing="5" summary="Enquiry Form">
<tr>
<td width="158"><p class="formtext">Your Requirements</p></td>
<td width="487"><label for="textarea"></label> <textarea name="requirements" id="requirements"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="Submit" value="Submit" id="Submit" style="background-color: #DEEFAD; color: #336633; border: 1 solid #3FBE7B;">
<input type="hidden" name="stage" value="process"> <input type="reset" name="Reset" value=" Reset" id="label" style="background-color: #DEEFAD; color: #336633; border: 1 solid #3FBE7B;"></td>
</tr>
</table>
</form>
<p><br>
</p>
<img src="images/bottom.gif" width="720" height="78" alt=""></div>
</div>
</body>
</html>

**End HTML**

Any help would be great, this has bugged me for days!

khalidali63
05-13-2003, 01:04 AM
Can you explain how to break you rcode..cusits running without crashingmy browser....

sametch
05-13-2003, 01:42 AM
It works fine on most browsers I have tested it on around 12, but on IE 5.5 on a W2K machine and on AOL 7.0 on a windows XP machine. This page crashes before fully loading. The page starts to load. Then the script tries to centralise the page, takes splits it in two immediately above the form element and crashes.

If I remove the form and replace with text. It works fine, so for some reason the script doesn't work with the form on these browsers.