LucasMars123 Posted April 29, 2013 Share Posted April 29, 2013 (edited) Can someone please give me some example code so I can link a webpage to another using javascript? This is my code at the moment:- document.onkeydown = function(e) { e = e || window.event; // because of Internet Explorer k = e.which || e.charCode || e.keyCode; // because of browser differences... if (k == 49 && !e.altKey && !e.ctrlKey && !e.shiftKey) { string.link(link.html) } else { return true; } return false; } This won't link me to the other link when "1" on the keyboard is pressed... Please Help! Edited April 30, 2013 by LucasMars123 Link to comment Share on other sites More sharing options...
thescientist Posted April 29, 2013 Share Posted April 29, 2013 Also, are you checking the error console for errors? I would imagine from that snippet there would be. im not sure where you got string.link from? to redirect to another page, you can change the window.location property, window.location = 'http://www.google.com'; 1 Link to comment Share on other sites More sharing options...
LucasMars123 Posted April 30, 2013 Author Share Posted April 30, 2013 Thanks! That works perfectly! I this links me straight to the page I want! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now