JS history.go()方法

history.go()方法

JavaScript中history.go()方法,可以用于从浏览器的历史列表中加载一个特定的url,应当注意的是,该方法只在页面存在于历史列表中才有效。


语法

history.go( number )

提示:参数number为数值类型值,为负数时,表示后退,整数时为前进,如果历史列表中当前页面有前一个页面的话,如果是0,则表示重新加载页面。


history.go()实例代码,及在线编辑器

点击实例运行后的按钮,将刷新当前页面:

<button onclick="go()">按钮</button>

<script>
  function go(){
    window.history.go(0)
  }
</script>

全栈前端 / JavaScript语法 :





















Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.