Skip to content

Instantly share code, notes, and snippets.

Created November 14, 2014 23:25
Show Gist options
  • Save anonymous/a3aa8b237300008b8f33 to your computer and use it in GitHub Desktop.
Save anonymous/a3aa8b237300008b8f33 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<p>Click the button to change the anchor part of the current URL to #part5</p>
<button onclick="changePart()">Try it</button>
<p id="demo"></p>
<script id="jsbin-javascript">
// Using the location.hash property to change the anchor part
function changePart() {
location.hash = "part5";
var x = "The anchor part is now: " + location.hash;
document.getElementById("demo").innerHTML = x;
}
// Alert some text if there has been changes to the anchor part
function myFunction() {
alert("The anchor part has changed!");
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">// Using the location.hash property to change the anchor part
function changePart() {
location.hash = "part5";
var x = "The anchor part is now: " + location.hash;
document.getElementById("demo").innerHTML = x;
}
// Alert some text if there has been changes to the anchor part
function myFunction() {
alert("The anchor part has changed!");
}</script></body>
</html>
// Using the location.hash property to change the anchor part
function changePart() {
location.hash = "part5";
var x = "The anchor part is now: " + location.hash;
document.getElementById("demo").innerHTML = x;
}
// Alert some text if there has been changes to the anchor part
function myFunction() {
alert("The anchor part has changed!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment