Example:
http://localhost/#view=1
If I want to get that variable "view", I need to get window.location.href, and then split the # and do something more.
This is my question:
<a href="#view=1">View 1</a>
<a href="#view=2">View 2</a>
Is there anyway to detect when View 1 click or view 2 click? For people click on View 2, a function will do for view=2.
OR I must do something like this:
<a href="#view=1" onclick="setview(1);">View 1</a>
<a href="#view=2" onclick="setview(2);">View 2</a>
I want when people copy the link http://localhost/#view=2 and send to there friend, the function setview(2) will be run when their friend visit the URL, and they don't need to click the link.
window.location.hashcan give you that directly. You shouldn't have to split your URL.onHashChangeevent.