I am ajax-ifying pagination in one of my projects, and since I want users to be able to add bookmarks to the current page, I add the page number via a hash, say:
onclick="callPage(2); window.location.hash='p=2'; return false;"
and thats on hyperlink it works fine and that’s all, except when the page number is 1, I don’t want the URL be /products#p=1 , I just want it to be /products
I tried these options:
window.location.hash='' works, but the url now looks like /products# , and I'm not really a hash there.- do not use window.location.hash at all, but when the user returns to page 1, for example, on page 3, he is on the first page, but the url is still
/products#p=3 , since I did not bother with the hash. - A Google search on this led me to several minutes (about 15) of stupid forums where the question was asked correctly, but the answers suggested that the page skipped because the creator of the stream had a hash in href like
<a href="#"> , and it should use javascript:void(0) instead. (have they never heard of Ajax?)
So, finally, I decided to make this thread, here I found several similar threads, but all the answers are very similar to my second point.
so my big question still remains the question: how to remove the hash from the url and possibly from the universe? (only for the first page!)
javascript ajax fragment-identifier
iamserious Dec 22 '10 at 11:13 2010-12-22 11:13
source share