Bug in my Javascript or bug in Firefox

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

    #1

    Bug in my Javascript or bug in Firefox

    Yesterday, I decided to try Firefox. I've encountered a behavior that is
    either a bug in Firefox or a bug in my Javascript code. I'll try to explain
    the problem, hoping that this newsgroup can (in)validate my Javascript code.

    First, I'll describe the purpose of the Javascript code.

    I often have a need to post a URL to something at my own web site, e.g.,
    http://www.standards.com/Sorting/Sor...scription.html.
    It is not easy to remember, or type without error, each URL, so I decided to
    write my first Javascript to be able to use
    http://www.standards.com/index.html?Sorting instead, which ends up going to
    http://www.standards.com/Sorting/Sor...scription.html.

    I then decided, perhaps for no good reason, to also allow
    http://www.standards.com/index.html#Sorting to mean the same as
    http://www.standards.com/index.html?Sorting. Of course, this works only if
    Javascript is enabled. To provide for those not having Javascript enabled,
    e.g., http://www.standards.com/index.html#Sorting will go to an anchor that
    links to a list of non-Javascript links.

    All seemed to work well using IE, but about 35 hours ago, I impulsively
    installed Firefox 1.0.

    Firefox seems to have a problem if the Javascript resolves, e.g.,
    http://www.standards.com/index.html#XXX to actually be
    http://www.standards.com/index.html#XXX, whilst IE has no problems. For
    example, use IE and Firefox with the links in
    http://www.standards.com/test-links-global.html.

    Is this a Firefox bug?
    Or am I doing something wrong in the Javascript in
    http://www.standards.com/links-index.js.
    If the latter, how can the Javascript be corrected with a client side
    solution?
    --
    http://www.standards.com/; See Howard Kaikow's web site.



  • Mick White

    #2
    Re: Bug in my Javascript or bug in Firefox

    Howard Kaikow wrote:
    [snip][color=blue]
    > http://www.standards.com/index.html#Sorting
    > http://www.standards.com/index.html?[/color]

    Perhaps?
    The newspaper of record, rebuilt for the information environment that exists in 2026. Free to read. Neutral by method. Independent by architecture. Built for the public.

    Rename your anchor "Sorting?Sortin g"
    Be sure to parse out "#Sorting" for your js browsers,
    Mick

    Comment

    • Lee

      #3
      Re: Bug in my Javascript or bug in Firefox

      Howard Kaikow said:[color=blue]
      >
      >Yesterday, I decided to try Firefox. I've encountered a behavior that is
      >either a bug in Firefox or a bug in my Javascript code.[/color]

      If you give Firefox an URL that doesn't exist, it will complain
      and refuse the load it. That doesn't seem unreasonable, to me.

      IE, apparently, will silently load the wrong address (the top of
      the page, ignoring the anchor specification).

      I don't see that as either a bug in Firefox or in your code.

      The problem sems to be that your design relies upon a quirk of IE
      that is not shared by Firefox.

      Comment

      • Howard Kaikow

        #4
        Re: Bug in my Javascript or bug in Firefox

        "Lee" <REM0VElbspamtr ap@cox.net> wrote in message
        news:codeae02mk f@drn.newsguy.c om...[color=blue]
        > If you give Firefox an URL that doesn't exist, it will complain
        > and refuse the load it. That doesn't seem unreasonable, to me.[/color]

        Yes, but the URL that is causing problems does exist, i.e., the anchor is in
        the index.html file.
        [color=blue]
        > IE, apparently, will silently load the wrong address (the top of
        > the page, ignoring the anchor specification).
        >
        > I don't see that as either a bug in Firefox or in your code.
        >
        > The problem sems to be that your design relies upon a quirk of IE
        > that is not shared by Firefox.[/color]
        If I cannot rely on Bill Gates, who can I rely on?


        Comment

        • RobG

          #5
          Re: Bug in my Javascript or bug in Firefox

          Howard Kaikow wrote:
          [...][color=blue]
          > If I cannot rely on Bill Gates, who can I rely on?[/color]

          If I click on your link:

          <URL:http://www.standards.c om/index.html#XXX>

          in Firefox 1.0, I am given an error prompt that the URL doesn't exist,
          then I'm taken to:

          <URL:http://www.standards.c om/index-js.html>

          IE does exactly the same thing. If that is your expected behaviour,
          then there is no issue regarding a difference in how IE or Firefox
          treat URLs with invalid anchors.

          --
          Rob

          Comment

          • Howard Kaikow

            #6
            Re: Bug in my Javascript or bug in Firefox

            XXX was just a placeholder in my posting. I stated:

            "For example, use IE and Firefox with the links in
            http://www.standards.c om/test-links-global.html."


            --
            http://www.standards.com/; See Howard Kaikow's web site.
            "RobG" <rgqld@iinet.ne t.auau> wrote in message
            news:sktqd.888$ I52.38162@news. optus.net.au...[color=blue]
            > Howard Kaikow wrote:
            > [...][color=green]
            > > If I cannot rely on Bill Gates, who can I rely on?[/color]
            >
            > If I click on your link:
            >
            > <URL:http://www.standards.c om/index.html#XXX>
            >
            > in Firefox 1.0, I am given an error prompt that the URL doesn't exist,
            > then I'm taken to:
            >
            > <URL:http://www.standards.c om/index-js.html>
            >
            > IE does exactly the same thing. If that is your expected behaviour,
            > then there is no issue regarding a difference in how IE or Firefox
            > treat URLs with invalid anchors.
            >
            > --
            > Rob[/color]


            Comment

            • Howard Kaikow

              #7
              Re: Bug in my Javascript or bug in Firefox

              I now see what is happening that is different between IE and Firefox.

              For example, using a URL of the form http://www.standards.com/index.html#XXX
              m where XXX is any of the 41 values that I specify in my javascript, IE
              does what I intended and takes the user to the correct page. Where XXX is
              "Standards: or "Temporary" or "ThisandTha t", the target document is actually
              index.html itself.

              IE handles all 41 cases as I intended, however, for the three targets that
              are actually in index.html, Firefox causes the script to be called a second
              time. The code looks like it is running correctly each time, i.e., it
              executes the following statement.

              location.replac e(URLList[locSearch]);

              Somehow, the 2nd pass thru the script using Firefox is causing a problem for
              those three cases.
              You can see the behavior by using IE and Firefox with the links in
              http://www.standards.com/test-links-global.html.


              Comment

              • Howard Kaikow

                #8
                Re: Bug in my Javascript or bug in Firefox

                Here's a corrected version of my previous message, i.e., less typos.
                --------------
                I now see what is happening that is different between IE and Firefox.

                For example, using a URL of the form
                http://www.standards.com/index.html#XXX,
                where XXX is any of the 41 values that I specify in my javascript, IE
                does what I intended and takes the user to the correct page. Where XXX is
                "Standards" or "Temporary" or "ThisandTha t", the target document is actually
                index.html itself.

                IE handles all 41 cases as I intended, however, for the three targets that
                are actually in index.html, Firefox causes the script to be called a second
                time. The code looks like it is running correctly each time, i.e., it
                executes the following statement.

                location.replac e(URLList[locSearch]);

                Somehow, the 2nd pass thru the script using Firefox is causing a problem for
                those three cases.
                You can see the behavior by using IE and Firefox with the links in
                http://www.standards.com/test-links-global.html.


                Comment

                • Dr John Stockton

                  #9
                  Re: Bug in my Javascript or bug in Firefox

                  JRS: In article <codeae02mkf@dr n.newsguy.com>, dated Sun, 28 Nov 2004
                  13:01:02, seen in news:comp.lang. javascript, Lee
                  <REM0VElbspamtr ap@cox.net> posted :[color=blue]
                  >Howard Kaikow said:[color=green]
                  >>
                  >>Yesterday, I decided to try Firefox. I've encountered a behavior that is
                  >>either a bug in Firefox or a bug in my Javascript code.[/color][/color]

                  Description was not reliably understood.

                  [color=blue]
                  >If you give Firefox an URL that doesn't exist, it will complain
                  >and refuse the load it. That doesn't seem unreasonable, to me.
                  >
                  >IE, apparently, will silently load the wrong address (the top of
                  >the page, ignoring the anchor specification).[/color]

                  A browser can only determine that an anchor does not exist by fetching
                  and examining the whole page. After fetching the whole page, ISTM
                  reasonable to show it; after all, there's a good chance of it's being
                  wanted. One would like to see a warning that the anchor was specified
                  but not found, though.
                  [color=blue]
                  >I don't see that as either a bug in Firefox or in your code.
                  >
                  >The problem sems to be that your design relies upon a quirk of IE
                  >that is not shared by Firefox.[/color]

                  ISTM bad Firefox design.

                  --
                  © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk DOS 3.3, 6.20; Win98. ©
                  Web <URL:http://www.merlyn.demo n.co.uk/> - FAQqish topics, acronyms & links.
                  PAS EXE TXT ZIP via <URL:http://www.merlyn.demo n.co.uk/programs/00index.htm>
                  My DOS <URL:http://www.merlyn.demo n.co.uk/batfiles.htm> - also batprogs.htm.

                  Comment

                  • Howard Kaikow

                    #10
                    Re: Bug in my Javascript or bug in Firefox

                    The anchor does exist.

                    --
                    http://www.standards.com/; See Howard Kaikow's web site.
                    "Dr John Stockton" <spam@merlyn.de mon.co.uk> wrote in message
                    news:+rsDWJCysy qBFwKN@merlyn.d emon.co.uk...[color=blue]
                    > JRS: In article <codeae02mkf@dr n.newsguy.com>, dated Sun, 28 Nov 2004
                    > 13:01:02, seen in news:comp.lang. javascript, Lee
                    > <REM0VElbspamtr ap@cox.net> posted :[color=green]
                    > >Howard Kaikow said:[color=darkred]
                    > >>
                    > >>Yesterday, I decided to try Firefox. I've encountered a behavior that is
                    > >>either a bug in Firefox or a bug in my Javascript code.[/color][/color]
                    >
                    > Description was not reliably understood.
                    >
                    >[color=green]
                    > >If you give Firefox an URL that doesn't exist, it will complain
                    > >and refuse the load it. That doesn't seem unreasonable, to me.
                    > >
                    > >IE, apparently, will silently load the wrong address (the top of
                    > >the page, ignoring the anchor specification).[/color]
                    >
                    > A browser can only determine that an anchor does not exist by fetching
                    > and examining the whole page. After fetching the whole page, ISTM
                    > reasonable to show it; after all, there's a good chance of it's being
                    > wanted. One would like to see a warning that the anchor was specified
                    > but not found, though.
                    >[color=green]
                    > >I don't see that as either a bug in Firefox or in your code.
                    > >
                    > >The problem sems to be that your design relies upon a quirk of IE
                    > >that is not shared by Firefox.[/color]
                    >
                    > ISTM bad Firefox design.
                    >
                    > --
                    > © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk DOS 3.3, 6.20;[/color]
                    Win98. ©[color=blue]
                    > Web <URL:http://www.merlyn.demo n.co.uk/> - FAQqish topics, acronyms &[/color]
                    links.[color=blue]
                    > PAS EXE TXT ZIP via[/color]
                    <URL:http://www.merlyn.demo n.co.uk/programs/00index.htm>[color=blue]
                    > My DOS <URL:http://www.merlyn.demo n.co.uk/batfiles.htm> - also[/color]
                    batprogs.htm.


                    Comment

                    • Howard Kaikow

                      #11
                      Re: Bug in my Javascript or bug in Firefox

                      I have managed to rewrite the script to avoid the problem with Firefox.

                      This does not explain why Firefox behaved differently than IE and Safari.

                      --
                      http://www.standards.com/; See Howard Kaikow's web site.
                      "Howard Kaikow" <kaikow@standar ds.com> wrote in message
                      news:codbc3$cil $1@pyrite.mv.ne t...[color=blue]
                      > Yesterday, I decided to try Firefox. I've encountered a behavior that is
                      > either a bug in Firefox or a bug in my Javascript code. I'll try to[/color]
                      explain[color=blue]
                      > the problem, hoping that this newsgroup can (in)validate my Javascript[/color]
                      code.[color=blue]
                      >
                      > First, I'll describe the purpose of the Javascript code.
                      >
                      > I often have a need to post a URL to something at my own web site, e.g.,
                      >[/color]
                      http://www.standards.com/Sorting/Sor...scription.html.[color=blue]
                      > It is not easy to remember, or type without error, each URL, so I decided[/color]
                      to[color=blue]
                      > write my first Javascript to be able to use
                      > http://www.standards.com/index.html?Sorting instead, which ends up going[/color]
                      to[color=blue]
                      >[/color]
                      http://www.standards.com/Sorting/Sor...scription.html.[color=blue]
                      >
                      > I then decided, perhaps for no good reason, to also allow
                      > http://www.standards.com/index.html#Sorting to mean the same as
                      > http://www.standards.com/index.html?Sorting. Of course, this works only if
                      > Javascript is enabled. To provide for those not having Javascript enabled,
                      > e.g., http://www.standards.com/index.html#Sorting will go to an anchor[/color]
                      that[color=blue]
                      > links to a list of non-Javascript links.
                      >
                      > All seemed to work well using IE, but about 35 hours ago, I impulsively
                      > installed Firefox 1.0.
                      >
                      > Firefox seems to have a problem if the Javascript resolves, e.g.,
                      > http://www.standards.com/index.html#XXX to actually be
                      > http://www.standards.com/index.html#XXX, whilst IE has no problems. For
                      > example, use IE and Firefox with the links in
                      > http://www.standards.com/test-links-global.html.
                      >
                      > Is this a Firefox bug?
                      > Or am I doing something wrong in the Javascript in
                      > http://www.standards.com/links-index.js.
                      > If the latter, how can the Javascript be corrected with a client side
                      > solution?
                      > --
                      > http://www.standards.com/; See Howard Kaikow's web site.
                      >
                      >
                      >[/color]


                      Comment

                      • Dr John Stockton

                        #12
                        Re: Bug in my Javascript or bug in Firefox

                        JRS: In article <cofu4o$ddq$1@p yrite.mv.net>, dated Mon, 29 Nov 2004
                        14:43:21, seen in news:comp.lang. javascript, Howard Kaikow
                        <kaikow@standar ds.com> posted :
                        [color=blue]
                        >Lines: 47[/color]
                        [color=blue]
                        >The anchor does exist.[/color]

                        Do learn FAQ section 2.3, including the first part of para 6.

                        I was responding to Lee's post, not to anything that you wrote.

                        --
                        © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME ©
                        Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
                        Web <URL:http://www.merlyn.demo n.co.uk/news-use.htm> : about usage of News.
                        No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.

                        Comment

                        • Howard Kaikow

                          #13
                          Re: Bug in my Javascript or bug in Firefox

                          Interested, or not, parties may follow the soap opera at
                          https://bugzilla.mozilla.org/show_bug.cgi?id=272126.

                          I've encountered two differences between IE and Firefox related to this
                          thread and have posted a PDF at
                          https://bugzilla.mozilla.org/show_bug.cgi?id=272126 describing how to
                          reproduce the behavior.


                          Comment

                          Working...