是否有一个功能,我可以附加作为一个按钮的点击事件,使浏览器回到上一页?

<input name="action" type="submit" value="Cancel"/>

当前回答

100%的工作

<一个onclick = " window.history.go (1);返回false;" style="光标:指针;“> < / >

其他回答

100%的工作

<一个onclick = " window.history.go (1);返回false;" style="光标:指针;“> < / >

你可以使用以下方法之一:

History.back()或window.history.back()

你还可以返回N个页面 history.go (1)

最短!

<button onclick="history.go(-1);">Go back</button>

http://jsfiddle.net/qXrbx/

我更喜欢.go(-number)方法,因为对于1个或多个“back”,只有一个方法可以使用/记住/更新/搜索等。

此外,使用标签作为返回按钮似乎比带有名称和类型的标签更合适……

每次对我都管用

<a href="javascript:history.go(-1)">
    <button type="button">
        Back
    </button>
</a>
history.back()

or

history.go(-1)

把这个放到按钮的点击手柄上。它应该是这样的:

<input name="action" onclick="history.back()" type="submit" value="Cancel"/>