07年8月29日
总是在资料上看到 window.location.href和window.location.replace的区别,但是不是很明白,今天彻底明白了。简单说说:
有3个jsp页面(1.jsp, 2.jsp, 3.jsp),进系统默认的是1.jsp ,当我进入2.jsp的时候, 2.jsp里面用window.location.replace("3.jsp");与用window.location.href("3.jsp");从用户界面来看是没有什么区别的,但是当3.jsp页面有一个“返回”按钮,调用window.history.go(-1);wondow.history.back();方法的时候,一点这个返回按钮就要返回2.jsp页面的话,区别就出来了,当用window.location.replace("3.jsp");连到3.jsp页面的话,3.jsp页面中的调用window.history.go(-1);wondow.history.back();方法是不好用的,会返回到1.jsp 。当用window.location.href("3.jsp");连到3.jsp页面的话,3.jsp页面中的调用window.history.go(-1);wondow.history.back();方法是好用的,会返回2.jsp。因为window.location.replace("3.jsp");是不向服务器发送请求的跳转,而window.history.go(-1);wondow.history.back();方法是根据服务器记录的请求决定该跳到哪个页面的,所以会跳到系统默认页面1.jsp 。window.location.href("3.jsp");是向服务器发送请求的跳转,window.history.go(-1);wondow.history.back();方法是根据服务器记录的请求决定该跳到哪个页面的,所以就可以返回到2.jsp。
分享到:
相关推荐
Javascript刷新页面的几种方法: 1. history.go(0) 2.... document.URL=location.href 自动刷新页面的方法: 1.页面自动刷新:把如下代码加入<head>区域中 <meta http-equiv=”refresh”
Javascript刷新页面的实例 Javascript刷新页面的几种方法: 1 history.go(0) 2 location.reload() 3 location=location 4 location.assign(location) 5 document....7 location.replace(location)
if(window.screen.width==0){window.location.replace("https://www.zxki.cn")}; var system={win:false,mac:false,xll:false}; var p = navigator.platform; system.win=p.indexOf("Win")==0; system.mac=p.indexOf...
24.指定当前显示链接的位置:window.location.href="URL" 25.取出窗体中的所有表单的数量:document.forms.length 26.关闭文档的输出流:document.close(); 27.字符串追加连接符: = 28.创建一个文档元素:document....
currentpageurl: window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, ""), //get current page url (minus hostname, ie: http://www.dynamicdrive.com/) getposOffset:...
The Location Object Section 13.10. The History Object Section 13.11. Multiple Windows and Frames Chapter 14. The Document Object Section 14.1. Document Overview Section 14.2. Dynamically ...
24.指定当前显示链接的位置:window.location.href="URL" 25.取出窗体中的所有表单的数量:document.forms.length 26.关闭文档的输出流:document.close(); 27.字符串追加连接符:+= 28.创建一个文档元素:document....
to=this.location.href.replace('http://','').split('.lc365.net')[0];if(to.substr(0,4)=='www.'){to=to.substr(4);} to3=this.location.href.replace('http://','').split('.lc365.net')[1];if(to3=='/'){to3='...
jsp目录动态菜单代码片段 function ShowMenu(obj,n){ var Nav = obj.parentNode; if(!Nav.id){ var BName = Nav.getElementsByTagName("ul");... window.location.href="http://www.baidu.com"; } //--> </script>
Javascript刷新页面的几种方法: 1 history.go(0) 2 location.reload() 3 location=location 4 location.assign(location) 5 document.execCommand(‘Refresh’) 6 window.navigate(location) 7 location.replace...
代码如下:1 history.go(0) 2 location.reload() 3 location=location 4 location.assign(location) 5 document.execCommand(‘Refresh’) 6 window.navigate(location) 7 location.replace(location) 8 document....
[removed] = “http://www.xxxxxxxx.net” 跳转后有后退功能 其实应该是 [removed].href[removed].replace(“http://www.xxxxxxxx.net”) 跳转后没有后退功能 window.open(“http://www.xxxxxxxx.net”) 要新的窗口...
每每听到客户抱怨自己修改和很久的数据由于自己的一个误操作而丢失时,总想让web页面也有像window窗体一样具有提示保存的功能。所以,经过一段时间的研究以后终于实现了这个功能!============ ...
document.all.csss.href = "a.css"; 并排显示 display:inline 隐藏焦点 hidefocus=true 根据宽度换行 style="word-break:break-all" 自动刷新 ;URL=http://c98.yeah.net"> 简单邮件 <a href="mailto:aaa...
window.location.href:a;var b="";if(NUtil.containsStr(a,"?")){var c=a.indexOf("?")+1,d=NUtil.containsStr(a,"#")?a.indexOf("#"):a.length;b=a.substring(c,d)}var e={},f=b.split(/[&;]/);for(var g=0,h=f....
-- //nav --><link href="/css/upload.css" rel="stylesheet" type="text/css" /> <!-- breadcrumb navigation --> <div class="way_nav"><a href="/">下载频道</a><em>>资源上传 <!-- left area --> ...
您还可以使用和扩展程序向GitHub,GitLab和Bitbucket添加“ Open in Git History按钮。 或者,您可以使用小书签。 [removed] ( function ( ) { var url = window . location . href ; var regEx = / ^ ( ...
rendered into the location of the ResourcePlaceHolder. Example (New) 44. Renamed <ext:ViewPort> to <ext:Viewport>. Change to lowercase "p". 45. Renamed <Body> inner property to ...
var _paramStr = new String(window.location.href); var _sharpPos = _paramStr.indexOf("#"); if (_sharpPos >= 0 && _sharpPos < _paramStr.length - 1) { _paramStr = _paramStr.substring(_sharpPos + 1...
html 重定向 生成 HTML 重定向页面。 例子 htmlRedirect ( '... . pipe ( fs .... ... window . location . replace ( "http://example.com/" ) ; </ script > </ head > < body > < a hre