Javascript examples for Browser Object Model:Location
The hash property sets or gets the anchor part of a URL, including the hash sign (#).
When setting the anchor part, do not include the hash sign (#).
Set the hash property with the following Values
Value | Type | Description |
---|---|---|
anchorname | String | Sets the anchor part of a URL |
A String, representing the anchor part of the URL, including the hash sign (#)
The following code shows how to Return the anchor part of a URL.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/* w w w. j ava 2 s . co m*/ var v = location.hash; document.getElementById("demo").innerHTML = v; } </script> </body> </html>