Problems Redirecting to a CSS Page Once NN6 & NN7 are Detected

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • that guy over there

    Problems Redirecting to a CSS Page Once NN6 & NN7 are Detected

    Ugh, am pulling my hair out over this one...

    I want to be able to format a page slightly differently depending on
    whether or not a user is visiting the site using either Netscape 6 or
    7.

    That bit I seem to have sorted out; my problem is getting the &*$%#
    link function to work from a document.write statement.

    For example, the following code correctly differentiates between the
    two Netscapes (at least on Windows):

    <html>
    <head>
    <script>
    // netscape browsers
    var is_nn6 = (navigator.prod uct == 'Gecko') &&
    (!window.find)? true:false;
    var is_nn7 = (navigator.prod uct == 'Gecko') &&
    (window.find)?t rue:false;
    </script>
    </head>
    <body>
    Netscape browsers<br>
    <script>
    document.write( "NN6:" + is_nn6 + "<BR>");
    document.write( "NN7:" + is_nn7 + "<BR>");
    </script>
    </body>
    </body>
    </html>

    But if I try adding the following code to the header of the page in
    order to redirect the page to point to separate .css files, I only get
    a page saying "Netscape browsers", so it is somehow blowing out the
    valid true or false values I get from the ternary statements.

    if (is_nn6)
    {document.write ("<link rel=\"styleshee t\"
    href=\"nn6.css\ "/>"};
    else if (is_nn7)
    {document.write ("<link rel=\"styleshee t\"
    href=\"nn7.css\ "/>"};

    What the heck am I doing wrong/am missing? Probably something silly
    and obvious, but I can't figure out what... Ugh. Help much
    appreciated.



  • Martin Honnen

    #2
    Re: Problems Redirecting to a CSS Page Once NN6 &amp; NN7 are Detected



    that guy over there wrote:[color=blue]
    > Ugh, am pulling my hair out over this one...
    >
    > I want to be able to format a page slightly differently depending on
    > whether or not a user is visiting the site using either Netscape 6 or
    > 7.
    >
    > That bit I seem to have sorted out; my problem is getting the &*$%#
    > link function to work from a document.write statement.
    >
    > For example, the following code correctly differentiates between the
    > two Netscapes (at least on Windows):
    >
    > <html>
    > <head>
    > <script>
    > // netscape browsers
    > var is_nn6 = (navigator.prod uct == 'Gecko') &&
    > (!window.find)? true:false;
    > var is_nn7 = (navigator.prod uct == 'Gecko') &&
    > (window.find)?t rue:false;
    > </script>
    > </head>
    > <body>
    > Netscape browsers<br>
    > <script>
    > document.write( "NN6:" + is_nn6 + "<BR>");
    > document.write( "NN7:" + is_nn7 + "<BR>");
    > </script>
    > </body>
    > </body>
    > </html>
    >
    > But if I try adding the following code to the header of the page in
    > order to redirect the page to point to separate .css files, I only get
    > a page saying "Netscape browsers", so it is somehow blowing out the
    > valid true or false values I get from the ternary statements.
    >
    > if (is_nn6)
    > {document.write ("<link rel=\"styleshee t\"
    > href=\"nn6.css\ "/>"};
    > else if (is_nn7)
    > {document.write ("<link rel=\"styleshee t\"
    > href=\"nn7.css\ "/>"};
    >
    > What the heck am I doing wrong/am missing? Probably something silly
    > and obvious, but I can't figure out what... Ugh. Help much
    > appreciated.[/color]

    Check the JavaScript console, if the code throws an error it will be
    reported there



    --

    Martin Honnen


    Comment

    • that guy over there

      #3
      Re: Problems Redirecting to a CSS Page Once NN6 &amp; NN7 are Detected

      On Mon, 11 Aug 2003 15:41:26 +0200, Martin Honnen
      <Martin.Honnen@ t-online.de> wrote:
      [color=blue]
      >
      >
      >that guy over there wrote:[color=green]
      >> Ugh, am pulling my hair out over this one...
      >>
      >> I want to be able to format a page slightly differently depending on
      >> whether or not a user is visiting the site using either Netscape 6 or
      >> 7.
      >>
      >> That bit I seem to have sorted out; my problem is getting the &*$%#
      >> link function to work from a document.write statement.
      >>
      >> For example, the following code correctly differentiates between the
      >> two Netscapes (at least on Windows):
      >>
      >> <html>
      >> <head>
      >> <script>
      >> // netscape browsers
      >> var is_nn6 = (navigator.prod uct == 'Gecko') &&
      >> (!window.find)? true:false;
      >> var is_nn7 = (navigator.prod uct == 'Gecko') &&
      >> (window.find)?t rue:false;
      >> </script>
      >> </head>
      >> <body>
      >> Netscape browsers<br>
      >> <script>
      >> document.write( "NN6:" + is_nn6 + "<BR>");
      >> document.write( "NN7:" + is_nn7 + "<BR>");
      >> </script>
      >> </body>
      >> </body>
      >> </html>
      >>
      >> But if I try adding the following code to the header of the page in
      >> order to redirect the page to point to separate .css files, I only get
      >> a page saying "Netscape browsers", so it is somehow blowing out the
      >> valid true or false values I get from the ternary statements.
      >>
      >> if (is_nn6)
      >> {document.write ("<link rel=\"styleshee t\"
      >> href=\"nn6.css\ "/>"};
      >> else if (is_nn7)
      >> {document.write ("<link rel=\"styleshee t\"
      >> href=\"nn7.css\ "/>"};
      >>
      >> What the heck am I doing wrong/am missing? Probably something silly
      >> and obvious, but I can't figure out what... Ugh. Help much
      >> appreciated.[/color]
      >
      >Check the JavaScript console, if the code throws an error it will be
      >reported there[/color]

      Doh! Was missing a ")" at the end of each line of the document.write
      statement. And Venkman lead me right to it, like you suggested. ;-)

      Ugh.

      Comment

      Working...