I have the following funciton that centers my website content for any size window and will center it in real time as the window is expanded or shrunk. It is activated by a
onresize="Cente rIt();"
in the body tag.
Works fine for IE. How do I make it compatible with netscape and most browsers? Better yet, is there a good single source that explains how to write javascript to be compatible with all browsers? 766 and 435 are the width and height of my table that surrounds the website data defined so:
<TABLE id="Main" style="position :absolute; z-index:0; top:0; left:0;">
function CenterIt()
{
newOffsetWidth = 0;
newOffsetHeight = 0;
if (document.getEl ementById)
{
winW = document.body.o ffsetWidth;
winH = document.body.o ffsetHeight;
}
else if (document.all)
{
/*
What goes here????
*/
}
else if (document.layer s)
{
/*
What goes here????
*/
}
if (winW > 766)
newOffsetWidth = ((winW - 766) / 2) - 10;
if (winH > 435)
newOffsetHeight = ((winH - 435) / 2);
if (document.getEl ementById)
{
document.getEle mentById('Main' ).style.left = newOffsetWidth;
document.getEle mentById('Main' ).style.top = newOffsetHeight ;
}
else if (document.all)
{
/*
What goes here????
*/
}
else if (document.layer s)
{
/*
What goes here????
*/
}
}
CenterIt();
Thanks!