Created
May 8, 2011 11:35
-
-
Save hkulekci/961314 to your computer and use it in GitHub Desktop.
Page navigation with Javascript and no jquery
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
<html> | |
<head> | |
<title>Example Page</title> | |
</head> | |
<body> | |
<div id="text"></div> | |
<script type="text/javascript"> | |
var urls = { | |
"37":"#previous-page",//left button | |
"39":"#next-page",//right button | |
"38":"#header",//top button | |
"40":"#comments",//bottom button | |
}; | |
var log_h = function(string){ | |
document.getElementById("text").innerHTML = string; | |
//window.location ... | |
} | |
var myKeyPressHandler = function(e) { | |
var unicode=e.keyCode? e.keyCode : e.charCode | |
if (urls[unicode] != undefined) | |
log_h(urls[unicode]); | |
} | |
document.onkeypress = myKeyPressHandler; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment