Netscape compatibility

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

    #1

    Netscape compatibility

    Hi,

    I need help : I found the simplest and most precise way to open and close
    submenu layers. it works perfectly with IE, but for some odd reason NS won't
    recognize it.

    Can anyone tell me why ?

    And is there a way around the problem ?

    I really like the elegance of this code and would like to keep using it.

    Thanks in advance.


    Roger Desparois


    <head
    <script language="Javas cript"`>
    <!--
    function Pop(name){
    eval("document. all."+name+".st yle.visibility= 'visible'");
    }
    function Wop(name){
    eval("document. all."+name+".st yle.visibility= 'hidden'");
    }

    //-->
    </script>
    </head>

    <body>
    <div id="prod"
    Style="backgrou nd-color:#ff0000;P osition:Absolut e;Left:39px;Top :89px;Width:1
    78px;Height:16p x;Visibility:vi sible;z-index:31" onmouseover="Po p('smprod')"
    onmouseout="Wop ('smprod')">
    <table width="178" height="16" border="0" cellspacing="0" cellpadding="0"
    class="menu">
    <tr>
    <td align="center" valign="middle" >Volleyball</td>
    </tr>
    </table>
    </div>

    <div id="smprod"
    Style="backgrou nd-color:#ff0000;t ext-align:right;Pos ition:Absolute; Left:39px
    ;Top:105px;Widt h:178px;Visibil ity:hidden;z-index:32"
    onmouseout="Wop ('smprod')" onmouseover="Po p('smprod')">
    <table width="178" border="0" cellspacing="0" cellpadding="0" class="menu">
    <tr>
    <td><img src="../images/espace1px.gif" width="178" height="5"></td>
    </tr>
    <tr>
    <td align="center" valign="top">
    <a href="../volleyball/en-ballons.html">B alls</a><br>
    <a href="../volleyball/en-souliers.html"> Shoes</a><br>
    <a href="../volleyball/en-genouillere.htm l">Kneepads</a><br>
    <a href="../volleyball/en-chevillere.html ">Ankle braces</a><br>
    <a href="../volleyball/en-filets.html">Ne ts</a><br>
    <a href="../volleyball/en-accessoires.htm l">Accessori es</a></td>
    </tr>
    <tr>
    <td><img src="../images/espace1px.gif" width="178" height="5"></td>
    </tr>
    </table>
    </div>
    </body


  • VK

    #2
    Re: Netscape compatibility

    Leaving out the question of the code elegance... I feel you came here for a
    quick-n-dirty solution and not for a JavaScript lessons:

    <script language="Javas cript"`>
    <!--
    function Pop(name){
    document.getEle mentById(name). style.visibilit y='visible';
    }

    function Wop(name){
    document.getEle mentById(name). style.visibilit y='hidden';
    }
    //-->
    </script>

    WHY??
    Because document.all is an Explorer's proprietary collection, other browsers
    do not support it.

    LATER MAY LOOK HERE:
    http://www.dynamicdrive.com/dynamicindex1/index.html
    (of course there are many similar places with even better code)




    Comment

    • George Hester

      #3
      Re: Netscape compatibility


      "VK" <schools_ring@y ahoo.com> wrote in message news:4167f9fa$0 $145$9b622d9e@n ews.freenet.de. ..[color=blue]
      > Leaving out the question of the code elegance... I feel you came here for a
      > quick-n-dirty solution and not for a JavaScript lessons:
      >
      > <script language="Javas cript"`>
      > <!--
      > function Pop(name){
      > document.getEle mentById(name). style.visibilit y='visible';
      > }
      >
      > function Wop(name){
      > document.getEle mentById(name). style.visibilit y='hidden';
      > }
      > //-->
      > </script>
      >
      > WHY??
      > Because document.all is an Explorer's proprietary collection, other browsers
      > do not support it.
      >
      > LATER MAY LOOK HERE:
      > http://www.dynamicdrive.com/dynamicindex1/index.html
      > (of course there are many similar places with even better code)
      >
      >
      >
      > [/color]

      Yes. documemt.all is IE. Here's a test for Netscape 6 and above I believe:

      ns6 = (!document.all && document.getEle mentById);
      //ns6 = true if Netscape 6+

      Netscape 4 is this:

      ns4 = (document.layer s);
      //ns4 = true if Netscape 4

      ie4 = (document.all && !document.getEl ementById);
      // ie4 = true Internet Explorer 4

      ie5 = (document.all && document.getEle mentById);
      // ie5 = true Internat Explorer 5 and up

      I'm not sure how to integrate Firefox and Opera in this scheme.

      Finally yes the scripting is fine for IE. You might consider fixing the CSS. Attributes are all lower case.
      Also the relative ../images may be able to change to /images. The trouble is that in new Microsoft web
      servers they have disabled relative adddressing without overhauling the new security relative addressing will no
      longer work.

      George Hester
      _______________ _______________ ____

      Comment

      • Michael Winter

        #4
        Re: Netscape compatibility

        On Sat, 09 Oct 2004 15:23:19 GMT, George Hester <hesterloli@hot mail.com>
        wrote:

        [snip]
        [color=blue]
        > Yes. documemt.all is IE.[/color]

        Opera also supports it, and I believe ICEBrowser does, too.

        [snip]
        [color=blue]
        > ns6 = (!document.all && document.getEle mentById);
        > //ns6 = true if Netscape 6+
        >
        > Netscape 4 is this:
        >
        > ns4 = (document.layer s);
        > //ns4 = true if Netscape 4
        >
        > ie4 = (document.all && !document.getEl ementById);
        > // ie4 = true Internet Explorer 4
        >
        > ie5 = (document.all && document.getEle mentById);
        > // ie5 = true Internat Explorer 5 and up[/color]

        Browser detection, whether by interpretation of the user agent string, or
        object inference, is fundamentally flawed. You don't *need* to know what
        browser you're using, just what it's capable of doing.

        Obviously you haven't read FAQ entry, 4.26.
        [color=blue]
        > I'm not sure how to integrate Firefox and Opera in this scheme.[/color]

        You don't.

        [snip]
        [color=blue]
        > The trouble is that in new Microsoft web servers they have disabled
        > relative adddressing without overhauling the new security relative
        > addressing will no longer work.[/color]

        I'm glad I use Apache.

        Mike

        --
        Michael Winter
        Replace ".invalid" with ".uk" to reply by e-mail.

        Comment

        • George Hester

          #5
          Re: Netscape compatibility

          "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message news:opsfl0sgpw x13kvk@atlantis ...[color=blue]
          > On Sat, 09 Oct 2004 15:23:19 GMT, George Hester <hesterloli@hot mail.com> [/color]
          [color=blue]
          > Obviously you haven't read FAQ entry, 4.26.
          >
          > Michael Winter
          > Replace ".invalid" with ".uk" to reply by e-mail.[/color]

          If you gave a link to the FAQ article you mention I would read it.
          Actually this came from soneone else on the Internet it is not mine. In any case how is it flawed?
          But of course if the article you mention answers that then that is what I would be looking for. Thanks.

          George Hester
          _______________ _______________ ____

          Comment

          • Lee

            #6
            Re: Netscape compatibility

            George Hester said:[color=blue]
            >
            >"Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message =
            >news:opsfl0sgp wx13kvk@atlanti s...[color=green]
            >> On Sat, 09 Oct 2004 15:23:19 GMT, George Hester =[/color]
            ><hesterloli@ho tmail.com> =20
            >[color=green]
            >> Obviously you haven't read FAQ entry, 4.26.
            >>=20
            >> Michael Winter
            >> Replace ".invalid" with ".uk" to reply by e-mail.[/color]
            >
            >If you gave a link to the FAQ article you mention I would read it.
            >Actually this came from soneone else on the Internet it is not mine. In =
            >any case how is it flawed?
            >But of course if the article you mention answers that then that is what =
            >I would be looking for. Thanks.[/color]

            You've been reading this newsgroup for an awfully long time
            to not know where to find the FAQ:



            Comment

            • Michael Winter

              #7
              Re: Netscape compatibility

              On Sat, 09 Oct 2004 15:54:24 GMT, George Hester <hesterloli@hot mail.com>
              wrote:
              [color=blue]
              > "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message
              > news:opsfl0sgpw x13kvk@atlantis ..[/color]

              [snip]
              [color=blue][color=green]
              >> Obviously you haven't read FAQ entry, 4.26.[/color][/color]

              [snip]
              [color=blue]
              > If you gave a link to the FAQ article you mention I would read it.[/color]

              The FAQ, and links to it, are posted three times a week. It exists in the
              signatures of several regular posters, and is mentioned plenty of times in
              responses to posts.

              You've posted to this group longer than I have. I shouldn't need to tell
              you where to find the article.
              [color=blue]
              > Actually this came from soneone else on the Internet it is not mine.[/color]

              So?
              [color=blue]
              > In any case how is it flawed?[/color]

              It isn't reliable and can, in some instances, entirely fail to identify
              the intended browser. Furthermore, scripts based on this technique often
              fail to work, or take advantage of new features, in future browser
              versions.

              [snip]

              Mike

              --
              Michael Winter
              Replace ".invalid" with ".uk" to reply by e-mail.

              Comment

              • Lasse Reichstein Nielsen

                #8
                Re: Netscape compatibility

                "George Hester" <hesterloli@hot mail.com> writes:
                [color=blue]
                > Yes. documemt.all is IE. Here's a test for Netscape 6 and above I believe:
                >
                > ns6 = (!document.all && document.getEle mentById);
                > //ns6 = true if Netscape 6+[/color]

                That also matches Opera 6 (unless identifying as IE) and Opera 5, and
                possibly also Safari and Konqeror (unless they decided to support
                document.all as well).
                [color=blue]
                > Netscape 4 is this:
                >
                > ns4 = (document.layer s);
                > //ns4 = true if Netscape 4[/color]

                Also matches OmniWeb.
                [color=blue]
                > ie4 = (document.all && !document.getEl ementById);
                > // ie4 = true Internet Explorer 4[/color]

                Also matches WebTV.
                [color=blue]
                > ie5 = (document.all && document.getEle mentById);
                > // ie5 = true Internat Explorer 5 and up[/color]

                Also matches Opera 7, and Opera 6 when identifying as IE.
                [color=blue]
                > I'm not sure how to integrate Firefox and Opera in this scheme.[/color]

                FireFox is based on the Mozilla project, just as the Mozilla Browser
                Suite and Netscape 6+. They act identically.

                Opera 7 is not distinguishable from IE 6 using only document.all and
                document.getEle mentById.


                Since there are many different browsers, and always more than an
                author expects, trying to recognize specific browsers is rarely
                a good idea. Because some people have tried doing it anyway, and
                have made pages that refuse to show themselves to some browsers,
                the users of those browsers frequently make their browser detect
                as another one, making detection even more impossible.

                If the existence of document.all/document.getEle mentById is releveant,
                because script is going to use those specific properties, then it
                makes sense to test for their presence. In that case, it doesn't
                matter what browser it is anyway.

                <URL:http://jibbering.com/faq/#FAQ4_26>

                /L
                --
                Lasse Reichstein Nielsen - lrn@hotpop.com
                DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
                'Faith without judgement merely degrades the spirit divine.'

                Comment

                • George Hester

                  #9
                  Re: Netscape compatibility


                  "Lee" <REM0VElbspamtr ap@cox.net> wrote in message news:ck926r04fv @drn.newsguy.co m...[color=blue]
                  > George Hester said:[color=green]
                  > >
                  > >"Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message =
                  > >news:opsfl0sgp wx13kvk@atlanti s...[color=darkred]
                  > >> On Sat, 09 Oct 2004 15:23:19 GMT, George Hester =[/color]
                  > ><hesterloli@ho tmail.com> =20
                  > >[color=darkred]
                  > >> Obviously you haven't read FAQ entry, 4.26.
                  > >>=20
                  > >> Michael Winter
                  > >> Replace ".invalid" with ".uk" to reply by e-mail.[/color]
                  > >
                  > >If you gave a link to the FAQ article you mention I would read it.
                  > >Actually this came from soneone else on the Internet it is not mine. In =
                  > >any case how is it flawed?
                  > >But of course if the article you mention answers that then that is what =
                  > >I would be looking for. Thanks.[/color]
                  >
                  > You've been reading this newsgroup for an awfully long time
                  > to not know where to find the FAQ:
                  >
                  > http://www.jibbering.com/faq/
                  > [/color]

                  well here we go. I went to the link and looked under 4.26: Here was their example that I assume is the way it is supposed to be done:

                  if (document.getEl ementById &&
                  document.getEle mentById('el') &&
                  document.getEle mentById('el'). style ) {
                  // We know that this browser supports getElementByID and has
                  // a style object, so we can set a style property.
                  document.getEle mentById('el'). style.color="re d";
                  }

                  That looks pretty familiar.

                  I didn't see anything about fundamentally flawed of what I presented earlier. Oh well thanks for the liink.

                  --
                  George Hester
                  _______________ _______________ ____

                  Comment

                  • Michael Winter

                    #10
                    Re: Netscape compatibility

                    On Sat, 09 Oct 2004 16:28:33 GMT, George Hester <hesterloli@hot mail.com>
                    wrote:

                    [snip]
                    [color=blue]
                    > well here we go. I went to the link and looked under 4.26: Here was
                    > their example that I assume is the way it is supposed to be done:[/color]

                    It's a way. It could be made more efficient by saving the references
                    obtained rather than repeated look-up.
                    [color=blue]
                    > if (document.getEl ementById &&
                    > document.getEle mentById('el') &&
                    > document.getEle mentById('el'). style ) {
                    > // We know that this browser supports getElementByID and has
                    > // a style object, so we can set a style property.
                    > document.getEle mentById('el'). style.color="re d";
                    > }
                    >
                    > That looks pretty familiar.[/color]

                    When compared to what?
                    [color=blue]
                    > I didn't see anything about fundamentally flawed of what I presented
                    > earlier. Oh well thanks for the liink.[/color]

                    Hmmm.

                    I take it you didn't read the linked pages in that entry.

                    Mike

                    --
                    Michael Winter
                    Replace ".invalid" with ".uk" to reply by e-mail.

                    Comment

                    • George Hester

                      #11
                      Re: Netscape compatibility


                      "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message news:opsfl2gwhn x13kvk@atlantis ...[color=blue]
                      > On Sat, 09 Oct 2004 15:54:24 GMT, George Hester <hesterloli@hot mail.com>
                      > wrote:
                      > [color=green]
                      > > "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message
                      > > news:opsfl0sgpw x13kvk@atlantis ..[/color]
                      >
                      > [snip]
                      > [color=green][color=darkred]
                      > >> Obviously you haven't read FAQ entry, 4.26.[/color][/color]
                      >
                      > [snip]
                      > [color=green]
                      > > If you gave a link to the FAQ article you mention I would read it.[/color]
                      >
                      > The FAQ, and links to it, are posted three times a week. It exists in the
                      > signatures of several regular posters, and is mentioned plenty of times in
                      > responses to posts.
                      >
                      > You've posted to this group longer than I have. I shouldn't need to tell
                      > you where to find the article.
                      > [color=green]
                      > > Actually this came from soneone else on the Internet it is not mine.[/color]
                      >
                      > So?
                      > [color=green]
                      > > In any case how is it flawed?[/color]
                      >
                      > It isn't reliable and can, in some instances, entirely fail to identify
                      > the intended browser. Furthermore, scripts based on this technique often
                      > fail to work, or take advantage of new features, in future browser
                      > versions.
                      >
                      > [snip]
                      >
                      > Mike
                      >
                      > --
                      > Michael Winter
                      > Replace ".invalid" with ".uk" to reply by e-mail.[/color]

                      I'm sorry Mike. I don't usually click on links unless I have an ovrriding need to. If it is to see what someone asks a question about or it may have information that I am interested in at the moment then I do. Otherwise not usually. That's just me which of course I have every right to be.

                      Not reliable seems weird. Not reliable means that sometimes ie5 will be false and sometimes true based on the direction the wind is blowing using IE5. That's a weird interpreter.

                      Take advantage of new features. Yes that true. But then IE 5, IE 6 NN4 NN6 ain't gonna get any newer as far as I know. So those variables I provided should always give the same vaues based on the use of those browsers. If they are not reliable then it is not an issue with the code it is an issue with the interpreter used in those browser. I didn't know that was a possibility. Thanks for pointing that out.

                      George Hester
                      _______________ _______________ ____

                      Comment

                      • George Hester

                        #12
                        Re: Netscape compatibility


                        "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message news:opsfl25pvj x13kvk@atlantis ...[color=blue]
                        > On Sat, 09 Oct 2004 16:28:33 GMT, George Hester <hesterloli@hot mail.com>
                        > wrote:
                        >
                        > [snip]
                        > [color=green]
                        > > well here we go. I went to the link and looked under 4.26: Here was
                        > > their example that I assume is the way it is supposed to be done:[/color]
                        >
                        > It's a way. It could be made more efficient by saving the references
                        > obtained rather than repeated look-up.
                        > [color=green]
                        > > if (document.getEl ementById &&
                        > > document.getEle mentById('el') &&
                        > > document.getEle mentById('el'). style ) {
                        > > // We know that this browser supports getElementByID and has
                        > > // a style object, so we can set a style property.
                        > > document.getEle mentById('el'). style.color="re d";
                        > > }
                        > >
                        > > That looks pretty familiar.[/color]
                        >
                        > When compared to what?
                        > [color=green]
                        > > I didn't see anything about fundamentally flawed of what I presented
                        > > earlier. Oh well thanks for the liink.[/color]
                        >
                        > Hmmm.
                        >
                        > I take it you didn't read the linked pages in that entry.
                        >
                        > Mike
                        >
                        > --
                        > Michael Winter
                        > Replace ".invalid" with ".uk" to reply by e-mail.[/color]

                        No as I explained earlier. I'm just that much of a clicker on the Net. The reason being
                        I have been burned too often. I'm sure the additional links are safe. But you must understand
                        that I use a Server with basically no security and signed on as Administrator. So I have to be very careful
                        what I do. I can operate this way have been for a very long time. I take no risks and I know where trouble lies
                        usually before it happens. Sometimes I fail but that hasn't happend since msblaster and even that was
                        innocuous for me. Did have trouble with coolwebsearch but I got that one licked too.

                        Oh the browser variables are in a js file called in the header. So they are never accessed but once when the
                        page loads.

                        George Hester
                        _______________ _______________ ____

                        Comment

                        • Andrew Thompson

                          #13
                          Re: Netscape compatibility

                          On Sat, 09 Oct 2004 17:06:19 GMT, George Hester wrote:
                          [color=blue]
                          > I'm just that much of a clicker on the Net. The reason being
                          > I have been burned too often.[/color]

                          You should try surfing with a browser, rather than
                          your OS component. Much safer.

                          --
                          Andrew Thompson
                          http://www.PhySci.org/codes/ Web & IT Help
                          http://www.PhySci.org/ Open-source software suite
                          http://www.1point1C.org/ Science & Technology
                          http://www.lensescapes.com/ Images that escape the mundane

                          Comment

                          • Richard Cornford

                            #14
                            Re: Netscape compatibility

                            Roger Desparois wrote:[color=blue]
                            > I need help : I found the simplest and most precise
                            > way to open and close submenu layers.[/color]

                            Simplicity is at least partly a matter of perception. One line of code
                            might seem to qualify but when that line of code combines a number of
                            actions, and eliminates much sensible checking and verification, the
                            simplicity is only really in its appearance.
                            [color=blue]
                            > it works perfectly with IE, but for some odd
                            > reason NS won't recognize it.[/color]

                            It is not that odd a reason. Any code that employs a Microsoft
                            proprietary feature should be expected to fail on a non-Microsoft
                            browsers (and often on non-default configurations, or non-Windows, IE).
                            [color=blue]
                            > Can anyone tell me why ?[/color]

                            The quick answer is the use of - document.all - as Netscape/Gecko
                            browsers have traditionally not implemented it (the most recent Mozilla
                            versions are implementing it as a concession to ancient code written in
                            the "both browsers" days without sensible feature detection. It seems
                            unlikely that a gecko browser with 'Netscape' in its name will be
                            released based upon the latest Mozilla code).
                            [color=blue]
                            > And is there a way around the problem ?[/color]

                            The simple act of showing/hiding a DOM element with CSS is achievable on
                            all dynamic, and many less-dynamic, browsers. Including some relatively
                            ancient browsers like Netscape 4, if the element in question is assigned
                            a CSS potion value of 'absolute' or 'relative', for the effort of adding
                            some extra lines of code.
                            [color=blue]
                            > I really like the elegance of this code and would like to
                            > keep using it.[/color]

                            It is a hack.

                            <snip>[color=blue]
                            > <head[/color]
                            ^
                            A closing '>' might be a good idea here.
                            [color=blue]
                            > <script language="Javas cript"`>[/color]

                            Script elements are required to include the TYPE attribute in HTML 4.
                            The language attribute is deprecated and becomes redundant when a TYPE
                            attribute is included:-

                            <script type="text/javascript">
                            [color=blue]
                            > <!--[/color]

                            These HTML comment-like sequences are unnecessary in current browser
                            scripting as they were introduced to address issues with browser that
                            have not been in use for some considerable time.
                            [color=blue]
                            > function Pop(name){
                            > eval("document. all."+name+".st yle.visibility= 'visible'");
                            > }[/color]

                            This is what you are describing as simplicity:-

                            1. Construct a string representing javascript source code.
                            2. Have that executed as a javascript program in a new eval
                            execution context. Starting a javascript interpreter,
                            have it interpret and execute the program and return the
                            result. A process consisting of:-
                            A. Resolve - document - against the scope chain and
                            retrieve a reference to that object (assuming it
                            exists, probably a safe assumption as - document -
                            is universal in HTML web browsers).
                            B. Resolve - all - as a named property of that object
                            and retrieve a reference to that object (it doesn't
                            exist in Netscape browsers so the value retrieved
                            in - undefined - not an object reference).
                            C. Resolve - style - as a named property of that object
                            (Netscape errors here as - all - was not an object) and
                            retrieve a reference to that object (assuming it exists).
                            D. Assign a string value to the - visibility - property of
                            that object.

                            The use of the - eval - contributes nothing to simplicity here, in the
                            source code or the execution of the code. It follows from nothing but
                            the author's ignorance of javascript as a language as it is being use to
                            dynamically insert one identifier in a dot notation property accessor.
                            Javascript has always offered the bracket notation property accessor as
                            a means of referencing objects using string value valuables (and
                            expressions) in place of identifiers. Simply using the bracket notation
                            in place of eval produces:-

                            document.all[ name ].style.visibili ty='visible';

                            (a much simpler line of code (and much simplified execution), though
                            equally error prone).

                            With the exception of the - document - reference (and some would include
                            that), everywhere that an assumption is made above a test to verify that
                            assumption is indicated. Simplicity achieved by omitting those tests is
                            not valuable simplicity.

                            Adding an implementation of the minimum testing might produced code
                            like:-

                            function Pop(name){
                            var el;
                            /* Only attempt to use the - document.all -
                            collection if it exists on this browser:-
                            */
                            if(document.all ){
                            el = document.all[ name ];
                            }
                            /* Verify that the DOM element retrieval happened
                            and returned a valid/usable object reference.
                            And then verify that the object reference has
                            a style property:-
                            */
                            if(el && el.style){
                            /* It should be safe (non-error producing) to
                            assign a value to 'visibility' the el.style
                            object (whether the browser assigned meaning
                            to that action is another question):-
                            */
                            el.style.visibi lity='visible';
                            }
                            }

                            Which has lost some of its original simplicity but will now not
                            error-out.

                            It still will not work with Netscape browsers as they do not implement -
                            document.all -. To get round that an alternative element retrieval
                            mechanism must be used. W3C Core DOM standard browsers provide a -
                            document.getEle mentById - method that is designed to retrieve a
                            reference to an element with a (unique) ID attribute that corresponds
                            with the string argument provided to the method call. These browsers
                            include IE 5.0+ and Netscape 6+ (and many others). This method is the
                            preferred method of retrieving such element references is it is most
                            wildly supported, - document.all - is now only a fall-back alternative
                            for ancient browser like IE 4 (and one or two others that are not going
                            to provide the - style - object anyway).

                            Again it is necessary to verify that the browser facilitates -
                            document.getEle mentByyId -, but if it does not - document.all - can be
                            tried as a fall back (alternative fall-back mechanisms can be used for
                            Netscape 4 under some circumstances). The modified code becomes:-

                            function Pop(name){
                            var el;
                            /* Only attempt to use the - document.getEle mentById -
                            if it exists on this browser:-
                            */
                            if(document.get ElementById){
                            el = document.getEle mentByI( name );

                            }else if(document.all ){ // else try - document.all -:-
                            el = document.all[ name ];
                            }
                            /* Verify that the DOM element retrieval happened
                            and returned a valid/usable object reference.
                            And then verify that the object reference has
                            a style property:-
                            */
                            if(el && el.style){
                            /* It should be safe (non-error producing) to
                            assign a value to 'visibility' the el.style
                            object (whether the browser assigned meaning
                            to that action is another question):-
                            */
                            el.style.visibi lity='visible';
                            }
                            }

                            The fact that the branching element retrieval mechanism is needed in
                            both functions, and is more involved than the original anyway, makes
                            this look considerably less simple. That follows from a failure to
                            recognise the real steps in this process. The first step in both the
                            setting of the property to 'visible' or ' hidden' is the retrieval of
                            the reference to the DOM element. Both functions must use the same
                            mechanism (and potentially much other code would require the same
                            facility). This suggests that element retrieval would be better done by
                            one separate function.

                            The notes to the newsgroup FAQ cover various approaches to implementing
                            a single IDed element retrieval mechanism is some detail but a simple
                            (and non-optimum) implementation might go:-

                            fucntion getElementWithI d(id){
                            if(document.get ElementById){
                            return document.getEle mentById(id);
                            }else if(document.all ){
                            return document.all[id];
                            }else{
                            return null; //no retrieval mechanism available
                            }
                            }

                            Reducing the original function to a simple:-

                            function Pop(name){
                            var el = getElementWithI d(name);
                            /* Verify that the DOM element retrieval happened
                            and returned a valid/usable object reference.
                            And then verify that the object reference has
                            a style property:-
                            */
                            if(el && el.style){
                            /* It should be safe (non-error producing) to
                            assign a value to 'visibility' the el.style
                            object (whether the browser assigned meaning
                            to that action is another question):-
                            */
                            el.style.visibi lity='visible';
                            }
                            }

                            - and having a similar simplifying effect on the internal code of both
                            functions.

                            The next step in the process, the verification of and referencing of the
                            style object, is also common to both functions (and again potentially
                            useful elsewhere). It would be possible to re-use the element retrieval
                            function code and wrap the style object handling around it, but element
                            retrieval is such a generally common requirement in browser DOM
                            scripting that the element retrieval function is probably best left
                            available to all code and a style object retrieval function designed to
                            call it for its element references. So the style object retrieval
                            function could go:-

                            function getStyleObjWith Id(id){
                            var el = getElementWithI d(id);
                            return (el && el.style)||el;
                            }

                            Reducing the original function to:-

                            function Pop(name){
                            var st = getStyleObjWith Id(name);
                            if(st){
                            st.visibility=' visible';
                            }
                            }

                            - and its counterpart to:-

                            function Wop(name){
                            var st = getStyleObjWith Id(name);
                            if(st){
                            st.visibility = 'hidden';
                            }
                            }

                            Which, while not as simple as one line of code, are relatively simple
                            and clear, will work on DOM standard browsers in addition to IE and will
                            not error-out on any browsers. (in addition, active support for
                            dinosaurs like Netscape 4, when such is possible, is now just a matter
                            of using a more involved element retrieval function (as can be found in
                            the FAQ notes) as everything down-stream of that is already in place and
                            cross-browser).

                            Richard.


                            Comment

                            • George Hester

                              #15
                              Re: Netscape compatibility


                              "Andrew Thompson" <SeeMySites@www .invalid> wrote in message news:kby0xsx78z r4$.y7ueorfgr6g 2.dlg@40tude.ne t...[color=blue]
                              > On Sat, 09 Oct 2004 17:06:19 GMT, George Hester wrote:
                              > [color=green]
                              > > I'm just that much of a clicker on the Net. The reason being
                              > > I have been burned too often.[/color]
                              >
                              > You should try surfing with a browser, rather than
                              > your OS component. Much safer.
                              >
                              > --
                              > Andrew Thompson
                              > http://www.PhySci.org/codes/ Web & IT Help
                              > http://www.PhySci.org/ Open-source software suite
                              > http://www.1point1C.org/ Science & Technology
                              > http://www.lensescapes.com/ Images that escape the mundane[/color]

                              I do surf with a browser. IE 5.5 to be exact. Is that the "component" you are referring to?
                              If so yeah I know. But that "component" is not as intractable as you may think. Just requires a little
                              extra work which sucks.

                              George Hester
                              _______________ _______________ ____

                              Comment

                              Working...