I want to have the user redirected to another page when any key is pressed. I know this is fairly simple to do, but I cannot seem to find anything to do it.
Thanks,
Tim
I want to have the user redirected to another page when any key is pressed. I know this is fairly simple to do, but I cannot seem to find anything to do it.
Thanks,
Tim
Last edited by TimFA; 03-14-2007 at 02:46 AM.
Code:<script type="text/javascript"> document.onKeyPress = function() { window.location = "anotherpage.html" } </script>
Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
Currently: enjoying the early holidays :)Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide
It's onkeypress, not onKeyPress: Javascript is case-sensitive. Also, using window.location like a string is a bit of a hack, and has inconsistent behaviour with other types of window (like frames). You want to provide something for non-JS browsers, too.<script type="text/javascript">
document.onKeyPress = function() { window.location = "anotherpage.html" }
</script>Code:<script type="text/javascript"> document.onkeypress = function() { location.href = "newpage.html"; }; </script> <noscript> <p> Please click <a href="newpage.html">here</a> to continue. </p> </noscript>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Thank you for your help.
Tim
Bookmarks