Forum Moderators: open
I am working on a website project. My aim is to dynamically resize the home page depending on the screen resolution ie 800 x 600 or 1024 x 768. I dont want to use % for table width coz if the screen resolution is higher the page will be distorted. The following script does the trick ... not for older browsers.. Specially Netscape 4.x
<html>
<head>
<title>Test</title>
<script language="JavaScript">
<!--
function wid(){
if(document.getElementById){
if(screen.width<=1024){
document.getElementById("TopTable").setAttribute("width", screen.width - 20);
}
else if(screen.width<=800){
document.getElementById("TopTable").setAttribute("width", 780);
}
else{
document.getElementById("TopTable").setAttribute("width", screen.width - 20);
}
}
else{
//Netscape 4.x script required
}
}
}
//-->
</script>
</head>
<body topmargin=0 leftmargin=0 onload="javascript:wid();">
<table id="TopTable" name="TopTable" border="0" cellpadding="3" cellspacing="0" bgcolor="#999999">
<tr><td>Check 1</td>
<td>Check 2</td>
</tr>
<tr><td>Check 3</td>
<td>Check 4</td>
</tr>
</table>
</body>
</html>