I was working on the back button support and bookmarkability of one of my galleries and by accident i have noticed there is a slight difference in behavior.
I wanted to change the url to differnet page but preserving the hash at the same time.
I wanted to jump on some event from page
So what i did was:
window.location.pathname = url_page_replace(window.location.pathname, parseInt(obj.page)) + window.location.hash;
I thought if i replace the path and append the hash to it everything would be cool but there is a difference. Opera and Chrome in such situation assume that i only wanted to change the path and they think i have put # hash just by accident. What they do is actually url encode that hash so when i get redirected i hit this page instead:
Little goole lookup on hash and window location made me realize my mistake.
What is the difference between window.location.pathname and window.location
If you override the full url by changing window.location than browser knows you want to change the url to the new one with hash string in it and there is no urlencoding added.
So what worked looked like this:
window.location = 'http://'+ domain + url_page_replace(window.location.pathname, parseInt(obj.page)) + window.location.hash;
The funny bit is that IE8, FF3 and Safari do not do this escaping so i thought it was some more serious problem :-)
I actually got the hint by looking at this page about window.location
Funny but true :- )