Created
February 24, 2015 05:09
-
-
Save jamc92/49d4e7731f9490cd9f63 to your computer and use it in GitHub Desktop.
JS - Document History
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Document History</title> | |
<meta charset="utf-8" /> | |
</head> | |
<body> | |
<script> | |
function go() { | |
//Go method to go forward or to go back with more than one page | |
window.history.go(); | |
//history.go(3) //Go forward 3 times | |
//history.go(-2) //Go back 2 times | |
} | |
function back() { | |
//Go back | |
window.history.back(); | |
} | |
function forward() { | |
window.history.forward(); | |
//Go forward | |
} | |
//history.length property says how many times you've been surfing on web sites | |
alert("Has visitado " + history.length + " páginas en la sesión del navegador") | |
</script> | |
<button onclick="forward()"> Forward </button> | |
<button onclick="back()"> Back </button> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Get Element By Id</title> | |
</head | |
><body> | |
<div id="myDiv"> | |
<p>Hello world</p> | |
</div> | |
<script> | |
var text = document.getElementById("myDiv").innerHTML; | |
alert(text); | |
var textChanged = document.getElementById("myDiv").innetHTML=" Hello Javascript"; | |
alert(textChanged); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment