Location hash Property - Set the anchor part: - Javascript Browser Object Model

Javascript examples for Browser Object Model:Location

Description

Location hash Property - Set the anchor part:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from   w w  w  . ja v  a2s.  c o m*/
    location.hash = "part5";
    var x = "The anchor part is now: " + location.hash;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials