View Full Version : Making it work in netscape!

01-18-2003, 07:19 AM
Ok I have a script that I want to use to make a div tag show in the dead center of the page works great in IE! but of course like everything else it doesnt work in netscape :) here is the script!

function fnInit() {

if(ie){DivID.style.setExpression("left", "document.body.clientWidth/2 - Welcome.offsetWidth/2");} if(ns){Welcome.setExpression("left", "innerWidth/2 - DivID.offsetWidth/2");}
if(ie){DivID.style.setExpression("top", "document.body.clientHeight/2 - Welcome.offsetHeight/2");} if(ns){Welcome.setExpression("top", "innerHeight/2 - DivID.offsetWidth/2");}


<div id="DivID" style="position:absolute;visibility:hidden">

document body content


so what do I replace the offsetWidth and the offsetHeight with for netscape? also what would work for the setExpression as the error I get in netscape is DivID is not defined.

01-18-2003, 09:07 AM
SO how Would I go About Defining the DivID?

01-18-2003, 10:54 AM
Whenever you reference a div, you should do it like this:


This method is supported in just about every version 5 browser.