Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Action when user hits the back button

Status
Not open for further replies.

kann

Programmer
Feb 16, 2000
25
0
0
US
Hi ,
I have a problem in with javascript,
When user hit the Browsers back button, my page(previous)should be Refreshed. Can i write javascript code to achive the above functionality.
thanks
kann
 
the simplest way, but maybe not most effecient, would be to write an onload refresh function for the page that requires the refresh. keep in mind you could go to that page from anywhere and it would still refresh upon loading, but that is still a way of acheiving this.

if you want to get a little more complicated, you could try writting an "else if" that says if the visitor is coming from this one page, then refresh it on the onload.

hope this helps! hurry up and wait!

aim screenname: phentalmyst

:D
 
Hi hoolz,
Thanks for ur reply. I coudl not get the result, because
when i try to use refresh(own func) on onLoad event, it is refreshing the page again and again.

kann
 
ack!! i totally didnt think of that. um, hmm..do me a favor, if you will, and explain to me the reasoning behind needing to go back to a refreshed page, that way maybe i could come up with something else.

thanks! hurry up and wait!

aim screenname: phentalmyst

:D
 
Hi hoolz,
I have a status page where i can allow the user to create
a duplicate reocrd if i have only one record exist.If already two record are there i won't allow the user to create another.
Suppose when the user navigate to status page first time,
there is only one record. He created the second one.Now you have two records. Again if he uses the 'Back' button
he can create one more duplicate record( but not as we wish), because previous page is not refreshed and allowed him. I think u understood my problem.
kann
 
hoolz,
i have a similar situation. when i click the back button i get error messages telling me that my select elements of the form don't support the options[] array or selectedIndex method. (im not sure which). i belive i can avoid this by not performing the functions if i can detect that the user has come from the page that the form submits to. you said in this thread earlier:

"if you want to get a little more complicated, you could try writting an "else if" that says if the visitor is coming from this one page, then refresh it on the onload."

i was wondering just how i can detect that they are coming from "this one page" (meaning a string URL that i could specify) any help is appreciated.
- ben
 
document.referrer should return a string contianing the url of the page that sent you here. then you can test against that string to see if your page should act normally (i think) jared@aauser.com
 
When you are creating your "records", you should check to see if it is a duplicate and not create one if it is. Then it wouldn't matter what page the user came from. Otherwise it would be possible to break your program anyway by simply sending the input from another source other than your website.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top