Web Analytics Made Easy -
StatCounter NS4 detection - CodingForum

Announcement

Collapse
No announcement yet.

NS4 detection

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NS4 detection

    Apologies for such a simple request, but my brain's fried.

    I need a javascript snippet that will detect NS4 exclusively and set a variable to 1 else set it to 2

  • #2
    Try searching you'll usually find somethinf similar:

    http://www.dynamicdrive.com/dynamicindex9/bredirect.htm

    which you can mod to do what you want:

    <script>
    var browser_type=navigator.appName
    var browser_version=parseInt(navigator.appVersion)
    //if NS4+
    if (browser_type=="Netscape"&&browser_version>=4) {
    myvar = 1;
    }
    //If NOT NS4+
    else {
    myvar = 2;
    }
    </script>

    Comment


    • #3
      Object detection is good in a pinch, but what if another script defines document.layers before the detection?

      For example, I am the project owner of http://layeremu.mozdev.org

      Which emulates everything to do with layers in Gecko. This includes defined document.layers as an array (collection).

      After applying this to a page:

      typeof document.layers != 'undefined'

      suddenly is true in NS4 AND NS6, NS7, Mozilla, K-meleon, Galeon, Beonex, etc - whatever Gecko browser they may be using.

      Just some food for thought.
      jasonkarldavis.com

      Comment


      • #4
        But shurely that doesn't matter since it will still work inside your emulator ... except that ns6 will be running the ns4 code instead of the (probably more attractive and powerful) gecko code ...

        just a thought. I've found object detection like that is only reliable if its done in the BODY section
        "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

        Comment


        • #5
          Originally posted by brothercake
          But shurely that doesn't matter since it will still work inside your emulator ... except that ns6 will be running the ns4 code instead of the (probably more attractive and powerful) gecko code ...
          Maybe and yes.

          Its hard to get perfect emulation - I'm still struggling with getting the clip properties all working, and siblingAbove/siblingBelow seem to currently have unpredictable behavior .
          I do have a draggable layer example though that works perfect in Gecko using NS4 layers.

          Anyway, I haven't run across your problem with object detection outside of the HTMLBodyElement yet, but then again lately I've only been writing stuff for Mozilla, and there are currently plenty of ways of having Mozilla see code that other browsers can't.
          (Such as language="Javascript1.5" in the script tag, or through a binding, etc).

          The only time I have something against object detection though is when it is actually used to determine the browser - I regularly use object detection to see if say an element supports addEventListener, but never use that check to determine that the browser is Gecko (Though I think Konqueror may also support addEventListener - probably mistaken though).

          jasonkarldavis.com

          Comment


          • #6
            I use always object detection. Reason is that I don't need to know what browser user has, but I need to know how to refer document's objects.

            For example, I don't care if someone emulates document.all hierarchy, as long as I can refer to objects with document.all[objectId].
            Zvona
            First Aid for
            Web Design

            Comment

            Working...
            X