bugzilla.mozilla.org will be intermittently unavailable on Saturday, March 24th, from 16:00 until 20:00 UTC.

removing hash from url doesn't work in Firefox when using ESC




2 years ago
5 months ago


(Reporter: vriad_lee, Unassigned)


43 Branch

Firefox Tracking Flags

(Not tracked)



(1 attachment)



2 years ago
Created attachment 8701826 [details]

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:43.0) Gecko/20100101 Firefox/43.0
Build ID: 20151216125248

Steps to reproduce:

I have a JS function that removes hash from the URL using this code:

window.location.href = window.location.href.split('#')[0];

The function is triggered by either clicking a certain page element or by pressing the ESC key. Both work perfectly in Chrome, but in Firefox, the ESC key does not remove the hash, while pressing the page element does. I've tried other ways of removing the hash part, such as


but with the same result. I know that the function IS triggered by the ESC key in FF, since other code inside it (such is hiding an overlay) executes successfully. 

Actual results:

 the escape key does execute the function, and the function does some work, but in Firefox it will not do the part of work that removes the hash. So the only combination when the bug is present is: FF + using ESC + modifying hash

Expected results:

The function should remove hash from the URL when the ESC is pressed.


2 years ago
OS: Unspecified → Linux
Hardware: Unspecified → x86

Could you please provide more detailed steps (Link to code or block of code) so I can attempt to reproduce?

Thank you,

Flags: needinfo?(vriad_lee)

Comment 2

2 years ago
Hi Justin,

I included an HTML file in the original post that has the code needed to reproduce the error. If you add a hash to the address of the page: delme.html#hash, then call the toggleOverlay() function by clicking the text on the page, the hash will be removed from the address; if you press ESC, which calls the same function, the hash is not removed. Just in case, here's the complete code:


function toggleOverlay(){
		window.location.href = window.location.href.split('#')[0];

function keyFunctions(event) {
    var x = event.keyCode || event.which;
        if (x == 27) {  // 27 is the ESC key
<body onkeydown="keyFunctions(event)">
<div onmousedown="toggleOverlay()">click this text to remove the hash (#) from the page address</div>
Flags: needinfo?(vriad_lee)
Sorry I did not see the attachment.

On my machine:

User Agent       Mozilla/5.0 (X11; Linux i686; rv:46.0) Gecko/20100101 Firefox/46.0
Version          46.0a1
Build ID         20151228030213

Pressing escape or clicking "love love love" works flawlessly. 

Could you please test:
1) in safe mode:

2) with a fresh profile:

Thank you,

Flags: needinfo?(vriad_lee)

Comment 4

2 years ago
I just tried both, with the same result: clicking the text works, pressing ESC doesn't.

My computer:
Build ID 	20151216125248
User Agent 	Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:43.0) Gecko/20100101 Firefox/43.0
Flags: needinfo?(vriad_lee)
Ok I am not sure what is different on the machines here and your machine as it was tested here on 3 different machines all on Linux i686 and various others MacOS and Win 8.1 and 10. Just to verify, you are testing your attachment? 

Please refer to https://support.mozilla.org/en-US/ as they can further assist you with this bug.
Last Resolved: 2 years ago
Resolution: --- → WORKSFORME

Comment 6

2 years ago
Yes - to be absolutely sure I downloaded the attachment and tried again, in both modes. I guess it must be some misconfiguration on my computer then. What surprises me is that in both Chrome and Chromium everything works fine on my machine. Anyway, thank you for taking the time to investigate this.
Moving from Core::Untriaged to Core::General https://bugzilla.mozilla.org/show_bug.cgi?id=1407598
Component: Untriaged → General
You need to log in before you can comment on or make changes to this bug.