Refresh when you go previous

T

Totti

Hi everyone,
I would like to ask you please answer the following:
On a BACK button that will send the user to a previous page, i would
like this "previous" page when one presses the button to go to it, to
refresh itself only once.
I have on a javascript on a backbutton onclick = "history.go
(-1);history.go(0);"
I thought this may work, but actually NO it doesnt.
I tried writing a method that will refresh onLoad but this one
refreshes for ever, I just need only to refresh once when someone
press this Back button, to take the user to the "refreshed" previous
page. is that possible?

Thanks in Advance
 
A

Alexander Ulizko

Hi everyone,
I would like to ask you please answer the following:
On a BACK button that will send the user to a previous page, i would
like this "previous" page when one presses the button to go to it, to
refresh itself only once.
I have on a javascript on a backbutton onclick = "history.go
(-1);history.go(0);"
I thought this may work, but actually NO it doesnt.
I tried writing a method that will refresh onLoad but this one
refreshes for ever, I just need only to refresh once when someone
press this Back button, to take the user to the "refreshed" previous
page. is that possible?

Thanks in Advance

You variant doesn't work because your code, that refreshes page
(history.go(0)) doesn't exist on the previous page. Browser "forget"
javascript that he left on the previous/another pages.
To store data or state of application and share them between pages you
need to use cookie.
You may implement desired behaviour in that way:

1. when user clicks "go back"
set cookie with name like "backButtonPressed"
2. on the previous page write method, that binds to onLoad event and
check if cookie with name 'backButtonPressed' exists,
if it is, than, delete cookie and refresh page
if it isn't, do nothing.

You can learn, how to work with cookies from javascript here:
http://www.w3schools.com/js/js_cookies.asp
 
D

David Mark

Never use history.go.
You variant doesn't work because your code, that refreshes page
(history.go(0)) doesn't exist on the previous page. Browser "forget"
javascript that he left on the previous/another pages.
Right.

To store data or state of application and share them between pages you
need to use cookie.

The idea of trying to control caching with cookies and script is
ridiculous.

[snip]
You can learn, how to work with cookies from javascript here:http://www.w3schools.com/js/js_cookies.asp

Don't use that site as a reference. It is full of mistakes.
 
A

Alexander Ulizko

The idea of trying to control caching with cookies and script is
ridiculous.

We both know that.
Also, we both know, that page refreshing doesn't clear cache if Keep-
Alive header for html setted or with aggressive caching behavior in
FF3+/Opera8.5+/Safari3+.
But also we both doesn't know, why exactly Totti need that behavior -
for control cache or for something else. I just offered a suggestion
of his problem as he described it.
Don't use that site as a reference.  It is full of mistakes.

Ok.
 
D

David Mark

We both know that.

I don't know what you know. My comment is to make it clear that this
suggestion is ridiculous.

[snip]
But also we both doesn't know, why exactly Totti need that behavior -

He said he wanted the page to "refresh" on navigation. What else
would that mean?
for control cache or for something else. I just offered a suggestion
of his problem as he described it.

And I noted that it was not a viable solution. That's how discussions
work.

[snip]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top