zoukankan      html  css  js  c++  java
  • 实现页面实现跳转的九种方法

    1 history.go(0)
    2 location.reload()
    location=location
    4 location.assign(location)
    5 document.execCommand('Refresh')
    6 window.navigate(location)
    7 location.replace(location)
    8 document.URL=location.href
    这几个都可以刷新
    window.location.reload();刷新
    window.location.href=window.location.href;刷新
    window.close();关闭窗口,不弹出系统提示,直接关闭 
    window.close()相当于self属性是当前窗口
    window.parent.close()是parent属性是当前窗口或框架的框架组
    页面实现跳转的九种方法实例:
    <html>
    < head>
    < meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    < title>navigate</title>
    < script language="javascript">
        setTimeout('window.navigate("top.html");',2000);
        setTimeout('window.document.location.href="top.html";',2000);
        setTimeout('window.document.location="top.html";',2000);
        setTimeout('window.location.href="top.html";',2000);
        setTimeout('window.location="top.html";',2000);
        setTimeout('document.location.href="top.html";',2000);              
        setTimeout('document.location="top.html";',2000);
        setTimeout('location.href="top.html";',2000);
        setTimeout('location.replace("top.html")',2000);
        //window对象
            //document对象
                //location对象
                    //href属性
                    //1.window.document.location.href
                    //2.window.document.location
                    //3.window.location.href
                    //4.window.location
                   
                    //5.document.location.href
                    //6.document.location
                    //7.location.href
                    //8.window.navigate
                    //9.location.replace
                    //只要使用location方法,和任意的window对象,location对象,href属性连用,都可以页面的跳转//// 
    < /script>
    < /head>

    < body>
    页面将在2秒后跳转
    < /body>
    < /html>

    解释:
    location是个对象,比如本页的document.location和window.location的属性有    
      location.hostname   =   community.csdn.net 
      location.href   =   http://community.csdn.net/Expert/topic/4033/4033372.xml?temp=2.695864E-02 
      location.host   =   community.csdn.net 
      location.hash   =   
      location.port   =   
      location.pathname   =   /Expert/topic/4033/4033372.xml 
      location.search   =   ?temp=2.695864E-02 
      location.protocol   =   http: 
      可见href是location的属性,类别是string。

  • 相关阅读:
    maven基础依赖外部lib包(依赖钉钉sdk为例)
    JVM的内存区域划分
    EF6 根据数据库字段说明,生成字段注释
    js上传图片,js图片转换为Base64
    Jquery用append()方法新增加的元素事件失效
    MVC添加区域路由问题
    JObject获取JSON格式字符串数据
    百度地图WebApi根据地址解析经纬度和根据经纬度解析地址
    sqlserver函数根据经纬度计算两点之间的距离
    AdminLTE-2.4.0-rc文件添加到项目中报错 错误 1 “tsc.exe”已退出,代码为 1。 M.Website
  • 原文地址:https://www.cnblogs.com/huiyi0521/p/9815089.html
Copyright © 2011-2022 走看看