Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting top.location.hash with %20 in firefox

In firefox, using this javascript:

top.location.hash = "#here%20are%20spaces";

changes the browser url to:

http://mysite.com/#here are spaces

I expected firefox to show the encoded spaces as %20 in the browser url.

  1. What's going on here? Why is firefox not setting the url to the string as I passed it?
  2. How can I force firefox to update the url with the encoded characters?

and...

If I add set the url to

top.location.hash = "#here%20are%20spaces%";

It works(!?), albeit with an extra unwanted % appended to the end. I am not sure if this is a bug or a feature. Ideas or references on how to proceed?

like image 927
jedierikb Avatar asked Dec 14 '25 19:12

jedierikb


2 Answers

%20 are replaced with an empty space (in firefox 3) just for readability purpose. You shouldn't worry about it.

like image 145
Luca Matteis Avatar answered Dec 16 '25 09:12

Luca Matteis


It still seems to be an active Firefox Bug for this issue (albeit reported for Firefox in Ubuntu, but also seen for other OS)....

like image 42
VonC Avatar answered Dec 16 '25 10:12

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!