Help! I'm fairly new to this and am trying to creating a training course that when the user hits the "enter" key they will be directed to the next training page. Thanks so much!!!
Lynn
Help! I'm fairly new to this and am trying to creating a training course that when the user hits the "enter" key they will be directed to the next training page. Thanks so much!!!
Lynn
If you have no other forms on your page, this is a neat way to do it:
Add to your body tag this onload event:
Then at the bottom of the page use this form:HTML Code:<body onload="document.forms[0][0].focus()">
just before the closing </body> tag. Substitute the name of the page you want this to switch to for both occurrences of blank.htm.HTML Code:<form action="blank.htm" onsubmit="location='blank.htm';return false"> <input type="submit" value="Next"> </form>
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
But if the user clicks something, focus will be lost. Better to use an event.
Code:<script type="text/javascript"> var page = "page2.htm" // Page to go to var key = 13; // Key to check for. 13 == enter. var ns6 = document.getElementById && !document.all ? 1 : 0; function goNext(ev) { if(ns6) if(ev.which === key) window.location.href = page; else if(ev.keyCode === key) window.location.href = page; } </script> </head> <body onkeypress="goNext(event);">
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!
Bookmarks