document.location.href和document.location.replace都可以实现从A页面切换到B页面,但他们的区别是:
用document.location.href切换后,可以退回到原页面。
而用document.location.replace切换后,不可以通过“后退”退回到原页面。
关于document.location.href或其他可回退的切换方式,我还发现一个细节,
用个例子来说明:
假设有A.htm B.htm C.htm三个页面
A.htm里有这样一句:document.location.href="b.htm";
b.htm里有这样一句:document.location.href="c.htm";
注意两个都是可回退的切换。
1:当从A切换到B再切换到C时,实际内存中保留了三个页面:A、B、C
2:回退到B时,C页面被清出内存!
3:再次回退,到A页面时,B页面也被清出内存!
4:再次向前(不是用切换而是用向前)转到B页面时,
分享到:
相关推荐
Javascript刷新页面的几种方法: 1. history.go(0) 2.... document.URL=location.href 自动刷新页面的方法: 1.页面自动刷新:把如下代码加入<head>区域中 <meta http-equiv=”refresh”
var parts = document.location.search.slice( 1 ).split( "&" ), length = parts.length, scripts = document.getElementsByTagName("script"), src = scripts[ scripts.length - 1].src, i = 0, current, ...
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 ...
currentpageurl: window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, ""), //get current page url (minus hostname, ie: http://www.dynamicdrive.com/) getposOffset:...
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>
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='...
Javascript刷新页面的几种方法: 1 history.go(0) 2 location....8 document.URL=location.href 自动刷新页面的方法: 1.页面自动刷新:把如下代码加入<head>区域中 <meta http-equiv=”refresh” content=”20
Javascript刷新页面的几种方法: 代码如下:1 history.go(0) 2 ...8 document.URL=location.href 自动刷新页面的方法: 1.页面自动刷新:把如下代码加入<head>区域中 代码如下:<meta http-equiv=”refresh”
24.指定当前显示链接的位置:window.location.href="URL" 25.取出窗体中的所有表单的数量:document.forms.length 26.关闭文档的输出流:document.close(); 27.字符串追加连接符: = 28.创建一个文档元素:document....
document.write('<a href="/zt/book/" target="_blank"><img src="/images/300x90-02.jpg" width="300" height="90" /></a>');} if (code=="in300x250"){ document.write('<script type="text/javascript" >BAIDU_...
Javascript刷新页面的实例 Javascript刷新页面的几种方法: 1 history.go(0) 2 location.reload() 3 location=location 4 location.assign(location) 5 document....7 location.replace(location)
document.all.csss.href = "a.css"; 并排显示 display:inline 隐藏焦点 hidefocus=true 根据宽度换行 style="word-break:break-all" 自动刷新 ;URL=http://c98.yeah.net"> 简单邮件 <a href="mailto:aaa...
var _paramStr = new String(window.location.href); var _sharpPos = _paramStr.indexOf("#"); if (_sharpPos >= 0 && _sharpPos < _paramStr.length - 1) { _paramStr = _paramStr.substring(_sharpPos + 1...
每每听到客户抱怨自己修改和很久的数据由于自己的一个误操作而丢失时,总想让web页面也有像window窗体一样具有提示保存的功能。所以,经过一段时间的研究以后终于实现了这个功能!============ ...
eval(direction.replace("X","movId_X").replace("Y","movIds_Y")); newLeaderId = movIds_Y+"|"+movId_X; if(isLoss(newLeaderId)){ alert("哈哈,输啦~~"); window.location.reload(); } if(newLeaderId ==...
• 2.7.htm undefinded和null的使用 • 2.8.htm 变量的优先级 • 2.9.htm 数值型数据 • 2.10.htm 数组数据类型 • 2.11.htm 字符串型转换为逻辑型数据 • 2.12....
• 2.7.htm undefinded和null的使用 • 2.8.htm 变量的优先级 • 2.9.htm 数值型数据 • 2.10.htm 数组数据类型 • 2.11.htm 字符串型转换为逻辑型数据 • 2.12....
-- //nav --><link href="/css/upload.css" rel="stylesheet" type="text/css" /> <!-- breadcrumb navigation --> <div class="way_nav"><a href="/">下载频道</a><em>>资源上传 <!-- left area --> ...
<link rel="stylesheet" type="text/css" href="style.css"> src="http://ditu.google.com/maps?file=api&v=2& key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ- i1QfUnH94QxWIa6N4U6...