Click to See Complete Forum and Search --> : history.back


JehovahsWord
10-20-2003, 05:56 PM
hi,

I'm making this script, and I want to put a back button on each page so the person can get back a page. But, the problem is that these are dynamic pages, and each page posts some information, and when I hit the back button internet explorer says that the information cannot be resent, that I have to click refresh for it to be resent. is there any way to get around this? it can get quite annoying. my button looks like this:

<input type="button" name="mybutton" value="back" onclick="top.history.back();" />

Brandon

Jona
10-20-2003, 11:02 PM
What server-side language are you using? I'd suggest not using JavaScript to link back (as it isn't supported by ~13% of users, and is not good for accessibility), and getting the refering document's URI. In PHP, it would be this...


<a href="<?php echo($_SERVER["HTTP_REFERER"]); ?>" title="Go to previous page.">Back</a>


[J]ona

JehovahsWord
10-21-2003, 04:22 AM
hi,


yeah I know that about php, but, the problem is that this all happens on index.php, just different things are posted to bring up different pages. that's why I was using javascript.

Brandon

Originally posted by Jona
What server-side language are you using? I'd suggest not using JavaScript to link back (as it isn't supported by ~13% of users, and is not good for accessibility), and getting the refering document's URI. In PHP, it would be this...


<a href="<?php echo($_SERVER["HTTP_REFERER"]); ?>" title="Go to previous page.">Back</a>


[J]ona

fritzmaas
10-21-2003, 10:55 AM
Try this

if(history.length >=0)(history.back() );

It works on my page

Webskater
10-21-2003, 11:13 AM
This is a caching issue. I use ASP pages. If I write:
<%Response.CacheControl = "no-cache"%>
and someone clicks the back button they will get the form must be re-submitted message.
If this is not on the page, even if the page has been built dynamically from database records, the previous version of the page displays.
Funny, I spend my life making sure people can't go back in case they submit multiple records or try to delete something they have already deleted.

JehovahsWord
10-21-2003, 11:55 AM
oh! that makes sense, because I did put that on my pages, in php, to have the page not be cached. Thanks for telling me that!

in reply to the last post, what does that code do? the following:

if(history.length >=0)(history.back() );

Brandon

Originally posted by Webskater
This is a caching issue. I use ASP pages. If I write:
<%Response.CacheControl = "no-cache"%>
and someone clicks the back button they will get the form must be re-submitted message.
If this is not on the page, even if the page has been built dynamically from database records, the previous version of the page displays.
Funny, I spend my life making sure people can't go back in case they submit multiple records or try to delete something they have already deleted.

jgestrella
10-22-2003, 12:03 AM
if you want to use ASP codes, you can use the REDIRECT command of asp...

if you will settle with the Javascript code you can use history.go(-1)

robot
10-22-2003, 02:16 AM
I met this qustion before. And my server is an embedded one, and does not support ASP, PHP, etc.
Originally posted by jgestrella
if you want to use ASP codes, you can use the REDIRECT command of asp...

if you will settle with the Javascript code you can use history.go(-1) :(

JehovahsWord
10-22-2003, 04:51 AM
hi,

no, I can't use asp, because the script uses php :). but I have it solved now because of the post saying about the page not being cached. so I took out the php code which made the page not be cached and now it works fine.

Brandon

Originally posted by jgestrella
if you want to use ASP codes, you can use the REDIRECT command of asp...

if you will settle with the Javascript code you can use history.go(-1)