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"是上一 ...
随机推荐
- php函数基础(一)
一.函数结构 1.构成部分: 关键字 function
- PLSQL直接通过客户端连接远程
- 转载 ASP.NET SignalR 与LayIM配合,轻松实现网站客服聊天室(三) 激动人心的时刻到啦,实现1v1聊天
ASP.NET SignalR 与LayIM配合,轻松实现网站客服聊天室(三) 激动人心的时刻到啦,实现1v1聊天 看起来挺简单,细节还是很多的,好,接上一篇,我们已经成功连接singalR服务器 ...
- Ajax技术 - (Asynchronous JavaScript + XML)
Ajax Ajax = 异步JavaScript和XML,Ajax是一种用于创建快速动态网页的技术. 通过在后台与服务器进行少量数据交换,Ajax可以使网页实现异步更新.可以再网页不重新加载的情况下, ...
- ubuntu 环境下向GitHub上传(push)每次都需要用户名密码问题
这里使用的系统环境是ubuntu16.04,通过Git向GitHub仓库pull/push,使用https方式每次都需要输入用户名和密码,是解决此问题的方法. 一.应该确保你的系统上已经安装了Git ...
- Thinkphp M方法出错,D方法却可以
错误回顾: M('Local')->find(); //报错 //错误信息:Table 'test.local' doesn't exist [ SQL语句 ] : SHOW COLUMNS F ...
- Java中字符串为什么不以\0结尾
Java中字符串为什么不以\0结尾 其实这个问题没有什么好说的,Java里面一切都是对象,是对象的话,字符串肯定就有长度,即然有长度,编译器就可以确定要输出的字符个数,当然也就没有必要去浪费那1字节的 ...
- LintCode_50 数组剔除元素后的乘积
题目 给定一个整数数组A. 定义B[i] = A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1], 计算B的时候请不要使用除法. 样例 给出A=[1, 2, 3], ...
- windows 下nginx配置ssl https支持
本文适合正式上线的配置,购买来的证书 私钥*.key文件需要先去掉密码 openssl rsa -in old.key -out new.key
- flask的基本操作
常用的SQLAlchemy字段类型 # coding:utf-8 from flask import Flask from flask_sqlalchemy import SQLAlchemy app ...