[thelist] Browser detection JS problem

Zoe Oughton zoe.oughton at btconnect.com
Wed Nov 1 11:35:30 CST 2000


Hi listees

I have a problem which I cannot get my head around!

I am setting up a page and want the content to sit in the top left corner
with no gaps, so I have put:
 marginwidth="0" marginheight="0" topmargin="0" leftmargin="0"
in the body tag, yes.

Now this works fine, until I place some browser detection JavaScript within
the head tags, then the content moves away from the left edge of the window
and if the browser window is enlarged the content moves further away from
the left edge!!! Yet my tables are a fixed width, and not centered.

If I remove the JavaScript the content sits neatly against the right edge
again!!  I don't understand what is happening.

This is the browser detection JavaScript I place in the head tags (done for
me by somebody else):

        <script type="text/javascript"><!--
if (parseInt(navigator.appVersion) >= 4) {
        var IE4 = (navigator.appVersion.indexOf("MSIE") > 0);
        var NN4 = (navigator.appName == "Netscape");
        var OS;
        if (navigator.appVersion.indexOf("Win") > 0) OS = "Windows";
        if (navigator.appVersion.indexOf("Mac") > 0) {OS = "MacOS";}
        switch (OS) {
          case "Windows":
            if (IE4 > 0) document.write ("<LINK href='ie.css'
rel='stylesheet' type='text/css'");
            if (NN4 > 0) document.write ("<LINK href='nn.css'
rel='stylesheet' type='text/css'");
            break;
          case "MacOS":
            if (IE4 > 0) document.write ("<LINK href='iemac.css'
rel='stylesheet' type='text/css'");
            if (NN4 > 0) document.write ("<LINK href='nnmac.css'
rel='stylesheet' type='text/css'");
            break;
          }
        }
// -->
        </script>

Does anyone have any idea why this is happening?

TIA

Zoe





More information about the thelist mailing list