history.back()
时间: 2023-09-01 21:10:59 浏览: 49
The history.back() method is a JavaScript function that allows you to move back one page in the browser's history. This method is used to trigger the browser to navigate back to the previous page, just like clicking the back button on the browser's toolbar.
For example, if a user has navigated from page A to page B, calling the history.back() method from page B will take them back to page A.
Here's an example of how to use the history.back() method:
```javascript
function goBack() {
window.history.back();
}
```
This function can be called from a button or link on a webpage to allow the user to easily navigate back to the previous page.
相关问题
history.back
history.back()是一个JavaScript方法,用于在浏览器中后退到上一个页面。它可以通过window.history.back()或者简写为history.back()来调用。\[1\]当使用history.back()方法后退时,原页面表单中的内容会被保留。\[2\]这意味着如果在原页面填写了表单内容,后退后再返回该页面,填写的内容仍然会存在。
#### 引用[.reference_title]
- *1* *2* *3* [vue监听浏览器返回](https://blog.csdn.net/baidu_30668495/article/details/102567984)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
怎么使用history.back
使用history.back方法可以实现回退到浏览器历史记录中的上一页。可以通过以下代码调用:
```
history.back();
```
该方法不需要参数,直接调用即可。它会将用户带回到上一个页面,就像用户点击浏览器的“后退”按钮一样。注意,该方法只能回退到浏览器历史记录中的上一页,如果历史记录中不存在上一页,则该方法不会有任何效果。