By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,483 Members | 1,052 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,483 IT Pros & Developers. It's quick & easy.

Bug in my Javascript or bug in Firefox

P: n/a
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.

Jul 23 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
Howard Kaikow wrote:
[snip]
http://www.standards.com/index.html#Sorting
http://www.standards.com/index.html?


Perhaps?
http://www.standards.com/index.html#Sorting?Sorting
Rename your anchor "Sorting?Sorting"
Be sure to parse out "#Sorting" for your js browsers,
Mick
Jul 23 '05 #2

P: n/a
Lee
Howard Kaikow said:

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.


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.

Jul 23 '05 #3

P: n/a
"Lee" <RE**************@cox.net> wrote in message
news:co*********@drn.newsguy.com...
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.
Yes, but the URL that is causing problems does exist, i.e., the anchor is in
the index.html file.
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.

If I cannot rely on Bill Gates, who can I rely on?
Jul 23 '05 #4

P: n/a
Howard Kaikow wrote:
[...]
If I cannot rely on Bill Gates, who can I rely on?


If I click on your link:

<URL:http://www.standards.com/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.com/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
Jul 23 '05 #5

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

"For example, use IE and Firefox with the links in
http://www.standards.com/test-links-global.html."
--
http://www.standards.com/; See Howard Kaikow's web site.
"RobG" <rg***@iinet.net.auau> wrote in message
news:sk*****************@news.optus.net.au...
Howard Kaikow wrote:
[...]
If I cannot rely on Bill Gates, who can I rely on?


If I click on your link:

<URL:http://www.standards.com/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.com/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

Jul 23 '05 #6

P: n/a
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 "ThisandThat", 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.replace(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.
Jul 23 '05 #7

P: n/a
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 "ThisandThat", 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.replace(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.
Jul 23 '05 #8

P: n/a
JRS: In article <co*********@drn.newsguy.com>, dated Sun, 28 Nov 2004
13:01:02, seen in news:comp.lang.javascript, Lee
<RE**************@cox.net> posted :
Howard Kaikow said:

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.

Description was not reliably understood.

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).
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.
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.


ISTM bad Firefox design.

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

P: n/a
The anchor does exist.

--
http://www.standards.com/; See Howard Kaikow's web site.
"Dr John Stockton" <sp**@merlyn.demon.co.uk> wrote in message
news:+r**************@merlyn.demon.co.uk...
JRS: In article <co*********@drn.newsguy.com>, dated Sun, 28 Nov 2004
13:01:02, seen in news:comp.lang.javascript, Lee
<RE**************@cox.net> posted :
Howard Kaikow said:

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.

Description was not reliably understood.

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).


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.
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.


ISTM bad Firefox design.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20;

Win98. Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links. PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm> My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also

batprogs.htm.
Jul 23 '05 #10

P: n/a
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" <ka****@standards.com> wrote in message
news:co**********@pyrite.mv.net...
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.

Jul 23 '05 #11

P: n/a
JRS: In article <co**********@pyrite.mv.net>, dated Mon, 29 Nov 2004
14:43:21, seen in news:comp.lang.javascript, Howard Kaikow
<ka****@standards.com> posted :
Lines: 47 The anchor does exist.


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.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 23 '05 #12

P: n/a
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.
Jul 23 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.