Forum Moderators: open

Message Too Old, No Replies

Need help: Table width for cross browser and screen resolution.

java script - dynamic table resize

         

anoop

10:23 am on Sep 19, 2003 (gmt 0)

10+ Year Member



Hi guys,

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>

RonPK

8:44 pm on Sep 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi anoop, welcome to WebmasterWorld!

As far as I know, there is no way to resize a table in Netscape 4. I guess you could try to create the table using document.write(), and a <noscript> version for your javascript-disabled visitors.

anoop

9:23 am on Sep 23, 2003 (gmt 0)

10+ Year Member



HI,

I guessed it .. thanks for your reply.