The default bug view has changed. See this FAQ.

document.location.hash="" executed as the first thing in the DOM doesn't work

RESOLVED FIXED in mozilla8

Status

()

Core
Document Navigation
P2
normal
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Sebastian, Assigned: bz)

Tracking

unspecified
mozilla8
x86
Mac OS X
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

6 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30

Steps to reproduce:

Visit the page below with #anything added to the URL

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>Hash test</title>
  <script type="text/javascript">
    document.location.hash="";
  </script>
</head>
<body>
  <p>The hash won't be set to <b>#</b> in Firefox. (At least in Firefox 5.0.1)</p>
</body>
</html>


Actual results:

The stuff after the hash was not removed.


Expected results:

The URL should be stripped of everything after the hash. That's how it works in all other browsers I've tested and strangely also in Firefox, if I move the script tag to the bottom of the body.

Try visiting http://www.sebastianrazola.com/test.html#thisshouldberemoved

Comment 1

6 years ago
Doesn't behave as expected in Firefox Nightly either (8.0a1 (2011-07-31), OS X 10.6)

Comment 2

6 years ago
Created attachment 549757 [details]
This is a working version

This is the change to the html referred to above that makes the document.location.hash work as in other browsers.
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Component: DOM → Document Navigation
QA Contact: general → docshell
I have a fix for this; just testing it now.
Assignee: nobody → bzbarsky
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P2
Created attachment 549794 [details] [diff] [review]
Change the location on hash changes even if we cna't scroll right then.
Attachment #549794 - Flags: review?(justin.lebar+bug)
Comment on attachment 549794 [details] [diff] [review]
Change the location on hash changes even if we cna't scroll right then.

r=me with typo in commit message fixed.
Attachment #549794 - Flags: review?(justin.lebar+bug) → review+
Yeah, I actually caught that right after posting the patch.
Whiteboard: [need landing]
Jens, thank you for reporting this bug!

Comment 8

6 years ago
The credit for finding and reporting it goes to Sebastian.

Thanks for the quick response and fix.
http://hg.mozilla.org/integration/mozilla-inbound/rev/158f91502fff
Flags: in-testsuite+
Whiteboard: [need landing]
Target Milestone: --- → mozilla8
http://hg.mozilla.org/mozilla-central/rev/158f91502fff
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.