• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

history.back problem

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using the history.back function to go back to a previous page. The problem is that the previous page contains a validation function, written in javascript, to validate the current page before going to the next page and when I click the back button on the next page to go to the previous page, the error message which popped up from the validation on the previous page, pops up again before loading the previous page.
Does anyone know what I can do so that the previous validation message does not pop back up again when I use the back button.
Any help is greatly appreciated.
Thank you,
Anthea
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The back button and history.back() have been the bane of most web app developers since, like... FOREVER. There is no easy fix that i have found, (and believe me i have looked.) But here are some ideas...
First of all, what triggers the validation method?
It sounds like the body onload event handler. If this is the case you might try to use a different handler.
If you can't change the the handler you might want to try to have the button regenerate the page supplying the valid data or disabling the validation routine altogether. This is a little combersome ,but it should work.
 
Anthea Blake
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for your response.
I don't have an event handler in my onload part of the page.
My validation handler is a javascript function that is called when the user clicks a button to go to the next page. History.back is called when the user clicks a button called "back" on the next page. I am not referring to the browser's back button, but my own back button I created for the page.

You mentioned that I could disable the validation altogether. Do you know how I could do this. Is there some function I could use?
Any help is appreciated.
Thank you,
Anthea
 
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anthea,
Are you creating something like an index of pages or something? If so, your best bet (least what I get from your message) is to set a hidden field on your page, once into it. Upon clicking the button set it to something else. Heres the small trick. When you do click the button check first on the state of the value in the hidden field. If it is, say, 1 coming in and it turns to 2 when you click the button to leave the page, it should be 2 when you go back to it as well. This way you know you have been there before. I hope this is something on the lines you were looking for.
Rob
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a useful link.
http://developer.netscape.com/docs/manuals/communicator/jsref/wina2.htm
One solution to your problem, is try to get the "history.current" location. Check the history.length. Also check to see if there are more history items that occur after the history.current. If they do, then you are sure that the user has hit the back button. i have not done this myself, but just and idea. Please do let us know if you have found out anything that works. One more idea could be using cookies.
 
Anthea Blake
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thank you very much for all your responses.

The page I am using is a form that contains a list of information that the user has to fill in. Before the user can go to the next page, the page is validated with javascript to see if any fields are missing. If any fields are missing an error message is displayed using javascript. The user then clicks ok on the error message, and fills in all the fields. Once all the fields are filled in, the user can then go to the next page. The problem I had was that the next page has an HTML "back" button that goes to the previous page. If a validation error had previously occured on the previous page, that error pops up again when I used history.back, even though the page was not loaded yet. So I needed to get rid of the error message popping up again when I go back to the previous page.
I'm not sure if I explained it well enough, but thanks a lot for all you responses. I am currently not using the "history.back" function anymore. I just decided to save the previous forms data in a temporary table and just reload the data that the user entered before they went to the next page.
Thanks a lot again
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic