首页 > 网站 > WEB开发 > 正文

window.location.href/replace/reload()--页面跳转+替换+刷新

2024-04-27 15:08:40
字体:
来源:转载
供稿:网友

一、最外层top跳转页面,适合用于iframe框架集top.window.location.href("${pageContext.request.contextPath}/Login_goBack");============================================================================================二、window.location.href和window.location.replace的区别 1.window.location.href=“url”:改变url地址; 2.window.location.replace(“url”):将地址替换成新url,该方法通过指定URL替换当前缓存在历史里(客户端)的项目,因此当使用replace方法之后,你不能通过“前进”和“后 退”来访问已经被替换的URL,这个特点对于做一些过渡页面非常有用!三、强制页面刷新 1.window.location.reload():强制刷新页面,从服务器重新请求! ============================================================================================四、window.location.reload();页面实现跳转和刷新 1 history.Go(0)2 location.reload()3 location=location4 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。

转自:http://blog.csdn.net/wuya145/article/details/9114603


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表