Reputation: 11240
I have created a HTML error page which has a button with text Try Again. When the user clicks this button I would like to reload the refering page.
Looking on Google there are a few ways to do this, but I am unsure of which is the best way that will work in the majority of browsers.
Anyone help?
Thanks,
AJ
Upvotes: 0
Views: 849
Reputation: 19358
You could use the history api:
<a href="javascript-required" onclick="history.go(-1);return false;">Try again</a>
Upvotes: 0
Reputation: 641
Most browsers have a window location object that has a reload function
window.location.reload()
So you button will look like
<input type="button" value="Reload Page" onClick="window.location.reload()">
Upvotes: 0
Reputation: 6088
try:
<input type="button" onclick="window.location.reload();" value="Try again" />
Upvotes: 0
Reputation: 413717
Your code that handled the original HTTP request resulting in the error knows that URL, so it should simply create a link back on the error page; just a simple link, or whatever else that's appropriate for your overall site design.
Do not rely on the HTTP "REFERER" value.
Upvotes: 2