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