View Full Version : Next Page

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!!!


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">
just before the closing </body> tag. Substitute the name of the page you want this to switch to for both occurrences of blank.htm.

10-07-2005, 08:05 AM
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;
<body onkeypress="goNext(event);">