开发者

HTML button that reloads refering page

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 a开发者_开发知识库m unsure of which is the best way that will work in the majority of browsers.

Anyone help?

Thanks,

AJ


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.


try:

<input type="button" onclick="window.location.reload();" value="Try again" />


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()">


You could use the history api:

<a href="javascript-required" onclick="history.go(-1);return false;">Try again</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜