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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help. History.back not refreshing.

Status
Not open for further replies.

alexc

Programmer
Feb 1, 2001
3
CA
Help,

I have a series of pages set up in a wizard fashion, user goes from page 1 to 2 to 3 etc. After they leave each page the data they have entered is submitted to a java servlet.

I have a button on my page which calls history.back() to take the user to the previous page.

If the user goes back a page the data they have entered is not there. If they referesh the page it shows. I have set my meta data as follows:

<META HTTP-EQUIV=&quot;refresh&quot;>
<META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html&quot;> <META HTTP-EQUIV=&quot;Cache-Control&quot; CONTENT=&quot;no-cache&quot;> <META HTTP-EQUIV=&quot;Pragma&quot; CONTENT=&quot;no-cache&quot;> <META HTTP-EQUIV=&quot;Expires&quot; CONTENT=&quot;0&quot;>

What I am trying to achieve is to have a button that sends the user to the previous page, showing what they have submitted to the server. For that to occur I need the previous page refreshed.

I thought the META tags would covere the refresh problem but they are not. Any help is appreciated.

Alex
 
Alex,

Going 'back' in a browser does not re-request the page from the server. Instead of using history.back() you could just navigate to the page, this would cause the browser to request the page from the server.

That of course will NOT provide a solution for when the user performs a back himself using the browser IDE rather than your HTML button.

Hope this helps
-pete
 
Hi,

Thanks for the reply. With regards to 'navigate to the page,' how would I structure a button to do that? Keep in mind that the page does not know where it came from. The order of pages is only known at run time.

Thanks for any help.


Alex
 
> I have a series of pages set up in a wizard fashion
> The order of pages is only known at run time.

Well that's not what your previous 'wizard' statement indicated.

Do you have server side code running? If so you might consider using session data and dynamically building the navigation sequence to provide your desired behavior.

If not, I suppose you can use client cookies to accomplish the same thing, but I don't even want to get my thought process thinking that way. B-)

Hope this helps
-pete
 
Hi, once again thanks for the reply. I should have been clearer in my first e-mail. I hava a java servlet that I could use to redirect the browser to the correct previous page but I was hoping for a simpler answer that would not include the web server.

Thanks

Alex
 
> redirect the browser to the correct previous page

I did not mean 'redirect'. I mean navigate. Use session data to enable your server code to determine which specific page the user should go to when they press your button. Then dynamically build the url to the page in your server code and place it in the client handler for the button click. For instance in JSP it would look something like this:

<%
String url = session.getValue(&quot;previousUrl&quot;);
%>

<input type=&quot;button&quot; onclick=&quot;document.location='<%=url%>'&quot; value=&quot;Go Back&quot;>


Hope this helps
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top