Firefox href bug
Author: Anton Savchenko (Software Engineer)
window.location is an object which contains information about the document URL. This object also exposes methods for URL modification. There is a known bug in Firefox when retrieving the location.hash property. This property returns the URL following the hash symbol(#), however unlike other browsers or any other location property the returned portion of the URL is automatically decoded.
- hash=#Fire fox
In order to simulate the same behavior as the other browsers the hash property should be passed to encodeURIComponent method.For more information on the location property check out the full documentation here.
Just to reiterate the point this issue only exists in Firefox and its a known bug. It’s likely that the behavior of the location.hash property will change in the future to match the other location properties.
Code example, use this for Firefox only!
var locationObject = Window.location; var correctHash = encodeURIComponent(location.hash);
Filed under: Uncategorized |