Closed
Bug 277456
Opened 20 years ago
Closed 20 years ago
document.location.hash is URI-decoded, .href isn't
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 483304
People
(Reporter: spam_from_bugzilla, Unassigned)
Details
Attachments
(1 file)
|
291 bytes,
text/html
|
Details |
If I visit foo.html#abc%20def, should the %20 be decoded to a space when I read from document.location? It seems that if I read from document.location.href I see the %20, while reading from document.location.hash I see a space. Internet Explorer always returns %20. As far as I can see this is not defined by any of the DOM specifications yet. I think I would prefer to get %20 in .hash since that is consistent with both the other browser and .href. Any thoughts? I will attach a simple demo. Appologies if this is already known. This is with Firefox 1.0.
| Reporter | ||
Comment 1•20 years ago
|
||
Comment 2•20 years ago
|
||
See discussion in bug 135309. In short, IE sometimes unescapes and sometimes doesn't, which means that for identical URIs it can show different location.hash values. We always unescape.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → WONTFIX
| Reporter | ||
Comment 3•20 years ago
|
||
Boris - sorry, can't think how I failed to find that bug. Must improve
Bugzilla-searching skills.
For the benefit of anyone who has the same problem: in summary, don't use
location.hash in multi-browser code. I use this:
function document_location_hash() {
var hr=document.location.href;
var p=hr.indexOf('#');
if (p>=0) {
return hr.substr(p+1);
} else {
return "";
}
}
Updated•16 years ago
|
Resolution: WONTFIX → DUPLICATE
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•