Javascript 页面中的返回按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13511679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 12:15:04  来源:igfitidea点击:

Go back button in a page

javascript

提问by Rithu

Possible Duplicate:
Go Back to Previous Page
get back to previous page

可能重复:
返回到前一页
回到前一页

How to get the previous page in javascript coding. Go to the previous page when click that back button.

如何在javascript编码中获取上一页。单击该后退按钮时转到上一页。

回答by Ramya

Here is the code

这是代码

<input type="button" value="Back" onclick="window.history.back()" /> 

回答by George

You can either use:

您可以使用:

<button onclick="window.history.back()">Back</button>

or..

或者..

<button onclick="window.history.go(-1)">Back</button>

The difference, of course, is back()only goes back 1 page but go()goes back/forward the number of pages you pass as a parameter, relative to your current page.

当然,不同之处在于back()仅返回 1 页,但go()返回/前进作为参数传递的页数,相对于当前页面。

回答by nickf

There's a few ways, this is one:

有几种方法,这是一种:

window.history.go(-1);

回答by vusan

onclick="history.go(-1)"Simply

onclick="history.go(-1)"简单地