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"是上一 ...
随机推荐
- Android SDK 开发指南
Android SDK 开发指南 视频详解 以下视频是对融云 Android SDK 开发使用的详细讲解,您可以在阅读文档时配合学习. 更多视频教程如下: CSDN 融云 Android SDK ...
- mysql 对数据库操作的常用sql语句
1.查看创建某个数据库的 创建语句 show create database mysql 这个sql语句的意思是 展示创建名为mysql的数据库的 语句.执行之后如下图所示 仿造上面这个创建语句 创建 ...
- 嘴巴题1 LA2531 足球联赛
LA2531 足球联赛 题目: 有n只队伍打比赛,给出每只队目前获胜和失败的场数,再给出两两队伍接下来的比赛场次,问你哪些队伍可能的冠军 (题面摘自http://blog.csdn.net/s_h_r ...
- mysqldump mysql数据库导出命令
mysqldump -u用户名 -p密码 数据库名 > 导出的文件名 例如: mysqldump -uroot -p123456 test > /var/test.sql 如果要压缩就用管 ...
- Ubuntu18.04 磁盘挂载在某目录下
简介 记录Ubuntu18.04 桌面版系统下实现某个磁盘挂载到自己想要的目录下,内容参考网上教程,此处为自己操作记录. 查看当前所有的磁盘信息 命令:sudo fdisk -l 从列出的信息中可以看 ...
- MVC的学习步骤
(1)搭建环境(2)如何完成Controller和 Model的映射(3)如何把值传给Controller(4)Controller如何把值传给viewer(5)异常处理(6)页面标签(7)文件上传( ...
- MySQL中一条更新语句是如何执行的
1.创建表的语句和更新的语句 这个表的创建语句,这个表有一个主键ID和一个整型字段c: mysql> create table T(ID int primary key, c int); 如果要 ...
- 2019.8.12 NOIP模拟测试18 反思总结
写个博客总是符合要求的对吧 回来以后第一次悄悄参加考试,昨天全程围观… 然后喜提爆炸120分wwwwwwwww T1用了全机房最慢的写法,导致改掉死循环T掉的一个点以后还是死活过不了最后一个点.T2全 ...
- API安全验证之JWT(JSON WEB TOKEN) OLCMS
假如www.olcms.com/getUserInfo获取用户信息,你怎么知道当前用户是谁?有人说登陆时候我把他UID写入session了,如果是API接口,没有session怎么办,那么就需要把UI ...
- Can you find it? HDU-2141 (二分查找模版题)
Description Give you three sequences of numbers A, B, C, then we give you a number X. Now you need t ...