Closed Bug 203900 Opened 21 years ago Closed 21 years ago

Setting non-exisiting fragment ID with JS throws error

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sjoerd, Unassigned)

Details

(Keywords: qawanted)

Attachments

(1 file)

The following line throws an error:
location = '#dummy';
when there is no anchor named dummy.
It worked in Mozilla build 20030312, but no longer in Phoenix build 20030411.

The expected behaviour is to change the location without error, and the page
should not scroll to an anchor (because there isn't a matching one).

I've been using fragment identifiers to store the state of dynamic html pages in
the location. This is a great technique because this allows the user to bookmark
the state of a dynamic page, and it's the only way to change the location that
does not result in a page reload.
Attached file Minimal testcase
Having a regression date would help a lot here.
Component: DOM Other → DOM Level 0
Keywords: qawanted
OS: Windows XP → All
QA Contact: gerardok → ashishbhatt
Hardware: PC → All
Is this by any chance caused by the fix for bug 188734? It seems as if we
intentionally throw exceptions from code that tries to scroll to an undefined
ref in non-quirks mode, but in quirks mode this should not throw an exception.
Is it so?
I don't think it's an error to set a fragment identifier that has no matching
anchor. At least I can't find any document that explicitly states so. So Mozilla
shouldn't throw an error in any mode.
You're asking the browser to do something it can't do, so it's reporting the
fact that it can't do it by throwing an exception. That makes a lot of sense to
me, but I can understand that we don't want to do that in quirks mode for
compatibility, and depending on what IE does in standards mode, we might have to
not throw an exception there either.
I'm asking the browser to do something it can do perfectly well, namely changing
the location to a different fragment ID. That this has a sideeffect that fails
is not important. If I set the location of another window or frame to a URL that
doesn't exists, then Mozillla doesn't throw an exception either.
Could this be fixed before Mozilla 1.4?

I've published a technique about a year ago that requires this bug to be fixed. 
http://w3future.com/weblog/stories/2002/05/04/urisForDynamicPages.xml

I'm using this in several sites, and I've heard from others that they've also
noticed their pages stopped working in Mozilla. Is there a certain keyword that
should be added for this kind of regression?
It should be noted that this is a regression.  

The navigation menu on my page http://www.freethought.ca/debate/about.php 
should add a fragment to the URL when used.  Corr4ect behaviour is noted in 
IE/Win and older Firebird/Mozilla builds.  Recent builds produce a javascript 
error.  
WFM WinXP 20030826
(tried testcase in quirks & standards mode)

Can anyone still see this?
This is fixed.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: