Javascript in netscap

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mayur

    Javascript in netscap

    Hello friends, pls tell me why this script not working in my netscap7.1
    onload function is (document.layer s)

    function load(){
    if(document.all ) alert("ie");
    if(document.lay ers) alert("ns");
    }
  • Andrew Urquhart

    #2
    Re: Javascript in netscap

    "Mayur" <mayur_vyas@ind iatimes.com> wrote in message
    news:ba9273f0.0 403010539.71482 396@posting.goo gle.com...[color=blue]
    > Hello friends, pls tell me why this script not working in my[/color]
    netscap7.1[color=blue]
    > onload function is (document.layer s)
    >
    > function load(){
    > if(document.all ) alert("ie");
    > if(document.lay ers) alert("ns");
    > }[/color]

    document.layers is not supported in that browser, use
    document.getEle mentById instead

    Please read http://jibbering.com/faq/#FAQ4_26
    --
    Andrew Urquhart
    - FAQ: http://jibbering.com/faq
    - Archive: http://groups.google.com/groups?grou...ang.javascript
    - Reply: https://www.andrewu.co.uk/about/cont...ject=Re%3A+clj


    Comment

    • Michael Winter

      #3
      Re: Javascript in netscap

      On 1 Mar 2004 05:39:38 -0800, Mayur <mayur_vyas@ind iatimes.com> wrote:
      [color=blue]
      > Hello friends, pls tell me why this script not working in my netscap7.1[/color]

      Knowing what you are trying to acheive might help.
      [color=blue]
      > onload function is (document.layer s)[/color]

      (document.layer s) is not a function. A more explicit example would be good.
      [color=blue]
      > function load(){
      > if(document.all ) alert("ie");[/color]

      Support for document.all does not indicate Internet Explorer. Opera, and
      no doubt other browsers, support the collection.
      [color=blue]
      > if(document.lay ers) alert("ns");[/color]

      Support for document.layers does not indicate Netscape. Netscape 7 will
      evaluate the expression, typeof document.layers , to undefined.
      [color=blue]
      > }[/color]

      Mike

      --
      Michael Winter
      M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

      Comment

      • Mayur Vyas

        #4
        Re: Javascript in netscap



        function load(){
        if(document.all ) alert("ie");
        if(document.lay ers) alert("ns");
        }

        thanks for reply.

        I have 5 div in my page and I want to identify all as array
        (document.layer s)
        and want to do something on it.

        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        • Randy Webb

          #5
          Re: Javascript in netscap

          Mayur Vyas wrote:[color=blue]
          >
          > function load(){
          > if(document.all ) alert("ie");
          > if(document.lay ers) alert("ns");
          > }
          >
          > thanks for reply.
          >
          > I have 5 div in my page and I want to identify all as array
          > (document.layer s)
          > and want to do something on it.
          >[/color]

          Did you bother reading the FAQ that was linked to?

          Netscape 7 does *not* support document.layers nor does it support
          document.all

          And on top of that, your test is utterly useless at identifying ie and
          ns, as there are a lot more browsers that support document.all than ie
          and more browsers that support document.layers than ns. There is even a
          browser that supports *both* of them so you would get both alerts. And
          not all versions of NS (6 and 7) support document.layers , they use
          document.getEle mentById as do most modern browsers. (I would say all
          modern browsers but as soon as I do someone will come up with one that
          doesn't)

          --
          Randy
          Chance Favors The Prepared Mind
          comp.lang.javas cript FAQ - http://jibbering.com/faq/

          Comment

          • Mark Preston

            #6
            Re: Javascript in netscap

            On 02 Mar 2004 04:58:18 GMT, Mayur Vyas <mayurv_in@yaho o.com> wrote:
            [color=blue]
            >I have 5 div in my page and I want to identify all as array
            >(document.laye rs)
            >and want to do something on it.
            >[/color]
            You can't - did you miss where you were told that already?
            "Documenrt. all" is a Microsoft extension (that happens to be managed
            by a lot more than MSIE - so is no good at all as a browser test)
            whereas "document.layer s" is an EARLY Netscape extension that works on
            more than just Netscape (but doesn't work on modern Netscape).

            You really, really do have to use "document.GetEl ementById ("id") - as
            you were told earlier/

            Comment

            • Thomas 'PointedEars' Lahn

              #7
              Re: Javascript in netscap

              Mayur Vyas wrote:
              [color=blue]
              > [...]
              > I have 5 div in my page and I want to identify all as array
              > (document.layer s) and want to do something on it.[/color]

              With proper quoting[1], you could have noticed that there is no
              "document.layer s" object in the Gecko DOM. You can, however,
              use a method of the W3C DOM to refer to the collection of
              "HTMLDivElement " objects:

              document.getEle mentsByTagName( "div")

              Similar to an Array object, an HTMLCollection object allows to
              access its elements through their zero-based index as properties
              of the object. Unlike an Array object, it also allows to access
              its elements through the name and/or ID of the element object,
              if set.

              Note that the above method is not supported in all
              DOMs, so you should test for it before using it:
              <http://pointedears.de. vu/scripts/test/whatami>


              PointedEars
              ___________
              [1] <http://www.netmeister. org/news/learn2quote.htm l>

              Comment

              Working...