I use ‘window.location.hash’ to add ‘#something’ to the URL without refreshing the page.
I want to know how to do the same but using a slash (/) instead of hash (#).
Why? I have navigation tabs and I use a jQuery and Ajax to dynamically load the data. When javascript is enabled, ‘#something’ is added to the end of the URL to get the data. When javascript is disabled, it redirects to ‘/something’. So I want to fake the same URL for both.
Instead of http://site.com/section#something -> http://site.com/section/something
Thanks.
You can use any combination after the hash you want, but the answer to your question is no, you can’t do what you’re asking without re-directing the user.
Being able to play with the URL without re-directing would be a security concern on some levels (can you change the domain too? why not?….see where this rabbit hole goes?). For example changing your URL via JavaScript to say:
http://www.mybank.com(why isn’t my bank using SSL? bad bank, bad!) would be a phishers dream…so browsers don’t allow messing with the URL like this at all…not without actually taking you there.