zoukankan      html  css  js  c++  java
  • js 返回上一个页面

    当前的url下标为0,所以window.history.go(-1)就是要定位到相对当前页面下标为-1的页面,也就是之前刚刚访问的页面。

     

    //返回上一页:
    window.history.go(-1);

    //返回两个页面:
     window.history.go(-2);

    history.back()和history.go(-1)都是返回之前页面,但是方法不同,所以是有区别的:

     

    history.back(-1)//直接返回当前页的上一页,数据全部消息,是个新页面

    history.go(-1)//也是返回当前页的上一页,不过表单里的数据全部还在

    <input type=button value=刷新 onclick="window.location.reload()">
    <input type=button value=前进 onclick="window.history.go(1)">
    <input type=button value=后退 onclick="window.history.go(-1)">
    <input type=button value=前进 onclick="window.history.forward()">
    <input type=button value=后退 onclick="window.history.back()"> //后退+刷新
    

      

    
    
  • 相关阅读:
    3. VIM 系列
    2. VIM 系列
    2. 修复FFMPEG 复用 PAT、PMT发送间隔小于25ms的错误
    1. VIM 系列
    RESTful风格API
    APIview的使用
    1.DRF初始化
    Linux下的django项目02
    Linux下的django项目01
    1,web项目工作流程
  • 原文地址:https://www.cnblogs.com/wqzn/p/15739847.html
Copyright © 2011-2022 走看看