sametch
05-13-2003, 06:33 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!:confused:
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!:confused: