[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5003
  • Last Modified:

Using javascript:history.go(-1) more effectively

After adding a record we use <a href="javascript:history.go(-1)">Return to whatever</a> to give the user a way to get back to the page they were viewing before adding a record.  An example of this would be adding an item to an existing order - they need to get back to the original order they added an item to.

the problem with history.go is that it doesn't actually set the hyperlink, it simply returns them to a cached page in their browser's history.  How can I make this so that it replaces the link with an actual URL?  I want the page to actually refresh when they go to it so the new record shows up...I don't want to do any javascript refreshes on the parent page or any sorry fixes like that..

Thanks alot,

Stankstank
0
stankstank
Asked:
stankstank
1 Solution
 
Chirag1211Commented:
For this you need to set the href value to the url / page which you need to redirect to

Try the following code

<a href="Default2.aspx">Test</a>

Regards,

Chirag Patel
0
 
JohnModigCommented:
My suggestion would be to keep the link as it is and instead prevent the browser to cache the page in question. If this page is an order page it is probably not a bad idea anyway.  Best practise is to do this server-side if possible. There are multiple ways of doing this, depending on what programming language your page is written in:

-------------------------
HTML
-------------------------
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">

Also, for IE you may want to use another set of head
 tags in the end of your page to prevent the buffer fill: http://support.microsoft.com/kb/222064


-------------------------
ASP or ASP.NET
-------------------------
<% Response.CacheControl = "no-cache" %>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %>


-------------------------
PHP
-------------------------
<?
  Header('Cache-Control: no-cache');
  Header('Pragma: no-cache');
  ?>


-------------------------
Coldfusion
-------------------------
<cfheader name="Expires" value="#Now()#">
<cfheader name="Pragma" value="no-cache">


-------------------------
JSP
-------------------------
<%
  response.setHeader("Cache-Control","no-cache");
  response.setHeader("Pragma","no-cache");
  response.setDateHeader ("Expires", 0);
  %>


Regards,
John


0
 
renjurdevanCommented:
if you dont want to cache you can specify

Response.Cache.SetCacheability (HttpCacheability.NoCache);

Regards
Renju
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now