View Full Version : Next Page
lynnrd
10-06-2005, 08:03 PM
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
jscheuer1
10-07-2005, 02:41 AM
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:
<body onload="document.forms[0][0].focus()">
Then at the bottom of the page use this form:
<form action="blank.htm" onsubmit="location='blank.htm';return false">
<input type="submit" value="Next">
</form>
just before the closing </body> tag. Substitute the name of the page you want this to switch to for both occurrences of blank.htm.
But if the user clicks something, focus will be lost. Better to use an event.
<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);">
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.