Reputation: 2018
I am building an ajax website and it loads pages when I click on the navigation buttons just fine but the issues come when I reload the page. Once I reload the page, The page defaults back to loading main.html
no matter what the url is. My hash is a little different, it looks like this /#!/
. How can I retrieve the url and loose everything except the /Path/
. For reference, this is what one of my urls looks like http://mysite.com/#!/account/settings
. How do I get just the account/settings
part of the url. Thanks a lot if I made any sense.
Upvotes: 0
Views: 75
Reputation: 94131
Use a regular expression. I'm not the best at regex but this works:
var oldLoc = 'http://mysite.com/#!/account/settings',
patt = /#!(.+)/,
newLoc = oldLoc.match(patt)[1]; // This returns `/account/settings`
http://jsfiddle.net/elclanrs/WUL6a/
Upvotes: 1
Reputation: 19750
Tried window.location.hash.replace('#!/', '')
?
By the way, you should stop using hashbangs, and start using HTML5 History API :)
Upvotes: 1