移动端返回事件

384 阅读1分钟

常用的移动端js返回事件

  1. history.length// 初始时,该值为1
  2. history.length // 访问三个网址后,该值为3
  3. history.go(-1);//后退一页
  4. history.go(1);//前进一页
  5. history.go(2);//前进两页
  6. history.go();//刷新当前页面
  7. history.go(0);//刷新当前页面
  8. history.back();//后退一页
  9. history.forward();//前进一页

超链接返回上一页

<a href="#" onClick="javascript:history.back(-1);">返回上一页</a>
<a href="#" onClick="javascript:history.go(-1);">返回上一页</a>`

用按钮的代码

<input type="button" name="Submit" onClick="javascript:history.back(-1); value="返回上一页"/>

图片代码

<a href="javascript:;" onClick="javascript:history.back(-1);">
    <img src="图片路径" title="返回上一页"/>
</a>

常用的返回事件,记录哦!