Javascript examples for DOM:HashChangeEvent
The newURL property returns the URL of the document, after the URL hash has been changed.
To get the URL that was navigated away from, use the oldURL property.
This property is read-only.
A String, representing the URL that is navigated to
When the hash has been changed, get the URL we are navigating to:
<!DOCTYPE html> <html> <body onhashchange="myFunction(event)"> <button onclick="changePart()">Test</button> <p id="demo"></p> <script> function changePart() {//from ww w. jav a2 s . c o m location.hash = "newHashValue"; } function myFunction() { document.getElementById("demo").innerHTML = "Previous URL: " + event.oldURL + "<br>New URL: " + event.newURL; } </script> </body> </html>