windows.open window.location.href的用法和区别
window.location.href 只能在当前页面打开,不能用新窗口打开
windows.open("URL","窗口名称","窗口外观设定"); 具体使用参数:http://www.w3school.com.cn/jsref/met_win_open.asp
window.open和location.href深入下去,还有以下区别
1.window.location是window对象的属性,而window.open是window对象的方法
window.location是你对当前浏览器窗口的URL地址对象的参考!
window.open是用来打开一个新窗口的函数!
2.window.open不一定是打开一个新窗口!!!!!!!!
只要有窗口的名称和window.open中第二个参数中的一样就会将这个窗口替换,用这个特性的话可以在iframe和frame中来代替location.href。
如<iframe name="aa"></iframe>
<input type=button onclick="window.open('1.htm','aa','')">和
<input type=button
onclick="self.frames['aa'].location.href='1.htm'">的效果一样
3.window.location或window.open如何指定target?
这是一个经常遇到的问题,特别是在用frame框架的时候
解决办法:
window.location 改为 top.location 即可在顶部链接到指定页
或
window.open("你的网址","_top");
用户不能改变document.location(因为这是当前显示文档的位置)。
window.location本身也是一个对象。
但是,可以用window.location改变当前文档 (用其它文档取代当前文档),而document.location不是对象。
服务器重定向后有可能使document.url变动,但window.location.href指的永远是访问该网页时用的URL.
大多数情况下,document.location和location.href是相同的,但是,当存在服务器重定向时,document.location包含的是已经装载的URL,而location.href包含的则是原始请求的文档的URL.
self.location.href="/url" 当前页面打开新页面,与默认的location.href 或者是windows.location.href 或者是 this.location.href 效果一样
parent.location.href="/url" 在父页面打开新页面
top.location.href="/url" 在顶层页面打开新页面
windows.open window.location.href的用法和区别的更多相关文章
- document.URL vs window.location.href All In One
document.URL vs window.location.href All In One document.URL 与 window.location.href 两者有啥区别 document. ...
- windows.open、 window.location.href
windows.open("URL","窗口名称","窗口外观设定");打开新窗口,window对象的方法 不一定打开新窗口,只要有窗口的名 ...
- window.location.href和window.open的几种用法和区别
使用js的同学一定知道js的location.href的作用是什么,但是在js中关于location.href的用法究竟有哪几种,究竟有哪些区别,估计很多人都不知道了. 一.location.href ...
- window.open和window.location.href的几种用法
windows.open("URL","窗口名称","窗口外观设定"); <A href="javascript:windo ...
- window.location.href问题,点击,跳转到首页
onClick="window.location.href='./';" 点击,跳转到首页. location.href=url Js中实现跳转 window.location.h ...
- [转载]window.location.href的用法(动态输出跳转)
无论在静态页面还是动态输出页面中window.location.href都是不错的用了跳转的实现方案 javascript中的location.href有很多种用法,主要如下. self.loca ...
- window.location.href
WEB设置首页 <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-f ...
- window.top.location.href 和 window.location.href 的区别
"window.location.href"."location.href"是本页面跳转. "parent.location.href" 是 ...
- 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法
"window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...
随机推荐
- Struts2启动问题:ClassNotFoundException: org...dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
错误信息: java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExec ...
- python函数当容器
def func(): pass func2 = func func2() i = [func,func2] for a in i: a() 函数名就是内存地址,加()代表执行
- LINUX使用 su 命令临时切换用户身份
1.su 的适用条件和威力 su命令就是切换用户的工具,怎么理解呢?比如我们以普通用户beinan登录的,但要添加用户任务,执行useradd ,beinan用户没有这个权限,而这个权限恰恰由root ...
- Luogu P2292 [HNOI2004]L语言(Trie+dp)
P2292 [HNOI2004]L语言 题面 题目描述 标点符号的出现晚于文字的出现,所以以前的语言都是没有标点的.现在你要处理的就是一段没有标点的文章. 一段文章 \(T\) 是由若干小写字母构成. ...
- 【html、CSS、javascript-9】jquery-选择器及过滤器
一.选择器与过滤器 选择器 实例 选取 * $("*") 所有元素 #id $("#lastname") id="lastname" 的元素 ...
- 微信小程序中自定义swiper轮播图面板指示点的样式
重置样式: .swiper{ width: 100%; height: 240px; margin-bottom: 0.5rem; position:relative; } div.wx-swiper ...
- JavaScript中this的指向2(转载)
1. 每个函数都包含两个非继承而来的方法:call()方法和apply()方法. 2. 相同点:这两个方法的作用是一样的. 都是在特定的作用域中调用函数,等于设置函数体内this对象的值,以扩充函数赖 ...
- java并发系列(四)-----源码角度彻底理解ReentrantLock(重入锁)
1.前言 ReentrantLock可以有公平锁和非公平锁的不同实现,只要在构造它的时候传入不同的布尔值,继续跟进下源码我们就能发现,关键在于实例化内部变量sync的方式不同,如下所示: /** * ...
- win10 基础上装一个 ubuntu 双系统
1.准备一个空闲的分区: 1)确定每个磁盘都已经是 EFI 分区格式,如果不是,可以使用分区工具,将分区都转成EFI (例如 DiskGenius 工具挺好) 2)选择一个剩余空间较大的压缩空间,压 ...
- 我悲惨的人生,该死的UPX壳,谁能救救我
一个程序,被加了UPX壳... 结果加壳的人把UPX脱壳的关键参数都给删除掉了,我现在连脱壳都脱不掉... 我从网上下载了UPX最新3.91版本的壳,复制了两个UPX.exe,本来互相加壳和脱壳都没 ...