Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    302
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question how to stop NS4 from seeing script....

    First of all, I realize that NS4 is basically dead. However, there are still a few out there using it. I have cursor trail script on a validated doctype xhtml 1.0 Transitional (thanks to Liorean for that!) that is throwing out a javascript error for NS4.

    I have done one of those @import url(style_insert.css); hacks to deal with some of NS4's vaguaries with CSS. The cursor trail CSS specs are inside .spanstyle. I placed
    .spanstyle {visibility:hidden} in the stylesheet for NS4 to read and

    Code:
    
    .spanstyle {
    	visibility:visible !important;
            overflow: hidden; 
    	position:absolute;
    	top:-50px;
    	font-size:small;
    	font-weight:bold;
    	font-style:italic;
    	color:#30f;
    	font-family: 'Book Antiqua', 'Apple Chancery', serif;
    } 
    
    in the stylesheet for the current browsers.

    The cursor trail message shows up in NS4 anyway along with the javascript error message at the bottom of the page.

    I tried applying the media="all" hack:

    Code:
    <script src="cursortrailhead.js" type="text/javascript" language="JavaScript" media="all"></script>
    but then the page no longer validates.

    Ideas?

    Here is the actual page:
    http://llizard.crosswinds.net/cwc/sh...ay_strict.html

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72 W. 48' 57" , 41 N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    having looked at the script, it seems to already have checks in place to determine whether NS4 is being used. since those don't seem to be working, and since i haven't got a copy of NS4 to test with, i think the SIMPLEST ( though certainly not the best ) solution would be the following:

    <script>
    if (!document.layers) {
    document.write('<script src="cursortrailhead.js" type="text/javascript" language="JavaScript"></' + 'script>');
    }
    </script>

    document.layers is not the best way to check for NS4, though. i'd recommend using a combination of window.navigator properties to check and make sure that you've really got NS4.

    generally speaking, i don't condone browser detection; i suggest object detection instead. however, in this particular case, i don't think it's much of an issue.
    Last edited by joh6nn; 05-07-2004 at 05:58 AM.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you use a language attribute at a version higher than ns4 understands then it won't parse the script:
    Code:
    <script language="javascript1.5" ... etc
    But that limits you to XHTML Transitional, because the language attribute is gone from Strict.
    Last edited by brothercake; 05-07-2004 at 06:24 AM.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    document.layers is not the best way to check for NS4
    why not? it's way better than the navigator object, which can be spoofed by Opera.

    document.layers is not supported by either IE or Ns6+/Moz, so surely it can only point to NN4.x!

    i use this to check for NN4.x:

    Code:
    if (document.layers && !document.all && !document.getElementById) bNN4=true;
    works a treat

  • #5
    Regular Coder
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    302
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by joh6nn
    having looked at the script, it seems to already have checks in place to determine whether NS4 is being used. since those don't seem to be working, and since i haven't got a copy of NS4 to test with, i think the SIMPLEST ( though certainly not the best ) solution would be the following:

    <script>
    if (!document.layers) {
    document.write('<script src="cursortrailhead.js" type="text/javascript" language="JavaScript"></' + 'script>');
    }
    </script>
    Yes, Joh6nn, the cursor trail script works in NS4 with doctype 4.0 Transitional but when I put it onto an xhtml page, it required a fix so that the script would work in NS7. The fix causes an error in NS4. I'm not sophisticated enough in Javascripting to figure out what to remove from the script so that NS4 won't even see it. (I've done a random hunt and peck removal system, using half-educated guesses - ending up only in failures)

    But your recommendation to use a browser detection script to call up the cursor trail works perfectly. I'm not a big fan of browser detection either but I think it's probably safe to use this one in this case. I made this small change:

    Code:
    language="JavaScript"><\/script>');

    Many thanks for this solution.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jbot
    why not?
    Because the layers object doesn't always exist- it only exists in the <head> section of a page if the rendering surface already contains a document. This means that if you sniff for document.layers in a script in the head section, and the page is the first page to be viewed in that browser session, the test will fail.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #7
    Regular Coder
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    302
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question

    Quote Originally Posted by brothercake
    Because the layers object doesn't always exist- it only exists in the <head> section of a page if the rendering surface already contains a document. This means that if you sniff for document.layers in a script in the head section, and the page is the first page to be viewed in that browser session, the test will fail.
    I'm sorry but I'm having a lot of difficulty understanding what you are saying there. Under what circumstances would the page be the first page to be viewed in the browser? I am presently using NS4 and opened the link to the cursortrail page with the browser detection script to stop it from rendering in NS4 in a new window. That means that it was the first page to be viewed in that browser session, doesn't it?

    (As expected, the cursor trail script did not run in NS4 and no javascript errors occurred.)

  • #8
    Regular Coder
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    302
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Do I also have to add a note that early versions of IE will not see the script?

    Brothercake's concerns that the browser detection script might not be the answer were hounding me. So I did some more hunting and pecking and I think I have blundered upon a tidier solution!

    Code:
    for (i=0; i<message.length; i++) {
    if (document.getElementById) {
    var thisspan = document.getElementById("span"+i).style;
    } else {
    var thisspan = eval((document.getElementById)?"document.span"+i:"span"+(i)+".style");
    }
    if (thisspan.posLeft) {
    thisspan.posLeft=xpos[i]+'%';
    thisspan.posTop=ypos[i]+'%';
    }
    if (!thisspan.posLeft) {
    thisspan.left=xpos[i]+'px';
    thisspan.top=ypos[i]+'px';
    }
    }
    }
    var timer=setTimeout(makebanner,30);
    }
    if (document.layers) {
    message=''
    }
    eval((document.getElementById)? was eval((document.layers)? in the original version.

    Having done this, have I also eliminated early versions of IE from seeing the script or will there be an error in ancient versions of IE? (The only IE I have - and that is under duress - is IE6.) I'm wondering if I need to change the empty message area to something like:

    Code:
    if (document.layers || document.all) {
    message=''
    }
    The new version of the page now works as expected on Win2K in NS4, NS7, firefox, IE6 and Opera7.

    new version of page:
    http://llizard.crosswinds.net/cwc/sh...ay_strict.html


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •