Page 1 of 1
Back Button
Posted: Fri Dec 10, 2004 4:53 am
by snicolas
Hi guys,
How to create a Back button that will be placed in a form and return to the referer page, without resubnitting values etc...
I tried javascript:history.back(), but it soesn't work.
thx
s
Posted: Fri Dec 10, 2004 5:02 am
by Weirdan
javascript:history.go(-1)
Posted: Fri Dec 10, 2004 5:04 am
by snicolas
yes, thank you i tried this, but in Mozilla, the (-1) does not redirect to previous page.
If you test this in Firefox, for example, you'll need to do a (-2) to return to correct page.
Posted: Fri Dec 10, 2004 5:16 am
by Weirdan
snicolas wrote:yes, thank you i tried this, but in Mozilla, the (-1) does not redirect to previous page.
If you test this in Firefox, for example, you'll need to do a (-2) to return to correct page.
I have tested it in FF 1.0 and it works for me. Here is complete html doc:
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<form action='' method='GET'>
<input type='button' name='back' value='Back' onClick='javascript:history.go(-1)'>
</BODY>
</HTML>
Posted: Fri Dec 10, 2004 5:45 am
by snicolas
In my example, i found that:
<input type="button" value="BACK" name='back' onClick="javascript:self.location='<?php echo $_SERVER['HTTP_REFERER']?>'">
was a better solution.
s
Posted: Fri Dec 10, 2004 5:57 am
by Chris Corbyn
Yes that works too. And of course it will be completely browser independent since it is parsed in the server
Posted: Fri Dec 10, 2004 6:28 am
by Weirdan
d11wtq wrote:Yes that works too. And of course it will be completely browser independent since it is parsed in the server
It will be browser dependent because some browsers do not send the referrer URL
