Page 1 of 1

User defined back/forward buttons

Posted: Sat Sep 20, 2008 3:40 pm
by Sheridan
Instead of using the browser back/forward buttons, I want to create my own on the web page. Anyone have an idea as to how this is accomplished?

Re: User defined back/forward buttons

Posted: Sat Sep 20, 2008 4:00 pm
by daniel142005
The easiest way would be to use javascript.

Example:

Code: Select all

<FORM>
<INPUT type="button" value="Click here to go back" onClick="history.back()">
<INPUT type="button" value="Click here to go forward" onClick="history.forward()">
</FORM>
You could also use something like:

Code: Select all

<FORM>
<INPUT type="button" value="Click here to go back" onClick="history.go(-1)">
<INPUT type="button" value="Click here to go forward" onClick="history.go(1)">
</FORM>
You can change the -1 and 1 to any number, This allows you to determine how far forward or back to take the viewer. Use a minus sign and a number to go back, or just a number to go forward.

The onclick can be applied to almost all html elements, img, a, div, etc.

Re: User defined back/forward buttons

Posted: Sun Sep 21, 2008 9:06 am
by Sheridan
This is beautiful code, clear straightforward. Only problem is when I run a page with it the machine gives that snarky "Done, but with errors" message and the buttons do not appear.

Does anyone know a way of making HTML errors visible or seeing the error log?