User defined back/forward buttons

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sheridan
Forum Newbie
Posts: 18
Joined: Sat May 31, 2008 1:50 pm

User defined back/forward buttons

Post 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?
daniel142005
Forum Newbie
Posts: 3
Joined: Sat Sep 20, 2008 3:32 pm

Re: User defined back/forward buttons

Post 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.
Sheridan
Forum Newbie
Posts: 18
Joined: Sat May 31, 2008 1:50 pm

Re: User defined back/forward buttons

Post 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?
Post Reply