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的用法和区别的更多相关文章

  1. document.URL vs window.location.href All In One

    document.URL vs window.location.href All In One document.URL 与 window.location.href 两者有啥区别 document. ...

  2. windows.open、 window.location.href

    windows.open("URL","窗口名称","窗口外观设定");打开新窗口,window对象的方法 不一定打开新窗口,只要有窗口的名 ...

  3. window.location.href和window.open的几种用法和区别

    使用js的同学一定知道js的location.href的作用是什么,但是在js中关于location.href的用法究竟有哪几种,究竟有哪些区别,估计很多人都不知道了. 一.location.href ...

  4. window.open和window.location.href的几种用法

    windows.open("URL","窗口名称","窗口外观设定"); <A href="javascript:windo ...

  5. window.location.href问题,点击,跳转到首页

    onClick="window.location.href='./';" 点击,跳转到首页. location.href=url Js中实现跳转 window.location.h ...

  6. [转载]window.location.href的用法(动态输出跳转)

    无论在静态页面还是动态输出页面中window.location.href都是不错的用了跳转的实现方案   javascript中的location.href有很多种用法,主要如下. self.loca ...

  7. window.location.href

    WEB设置首页 <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-f ...

  8. window.top.location.href 和 window.location.href 的区别

    "window.location.href"."location.href"是本页面跳转. "parent.location.href" 是 ...

  9. 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法

    "window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...

随机推荐

  1. CPA专业阶段单科成绩有5年有效期限,即从通过科目考试的第一年算起

    你为什么不去参加注册会计师考试? 注册会计师考试出考率极低,大家都有自己的原因,可以客观地说,每年注会考场出考人数不足三成,到底是什么原因不去考试呢?大家是这么说的. 1.没有好好复习呗,还怎么去考试 ...

  2. Delphi 设计模式:《HeadFirst设计模式》Delphi7代码---观察者模式之WeatherReport[转]

      1   2{<HeadFirst设计模式>之观察者模式 }   3{ 主题与观察者                    }   4{ 编译工具 :Delphi7.0          ...

  3. Redis源码解析:13Redis中的事件驱动机制

    Redis中,处理网络IO时,采用的是事件驱动机制.但它没有使用libevent或者libev这样的库,而是自己实现了一个非常简单明了的事件驱动库ae_event,主要代码仅仅400行左右. 没有选择 ...

  4. 威胁快报|首爆新型ibus蠕虫,利用热门漏洞疯狂挖矿牟利

    一.背景 近日阿里云安全团队发现了一起利用多个流行漏洞传播的蠕虫事件.黑客首先利用ThinkPHP远程命令执行等多个热门漏洞控制大量主机,并将其中一台“肉鸡”作为蠕虫脚本的下载源.其余受控主机下载并运 ...

  5. CF 578B "Or" Game

    传送门 解题思路 题意大概是给你一个数列,可以进行k次操作,每次操作可以选择一个数乘x,问操作后的或的最大值.根据位运算,位数越高答案越优,所以贪心的使这k次操作全都放到一个数上,这样的结果肯定较优. ...

  6. clientHeight、offsetHeight 区别 笔记

    一张图 说明全部 clientHeight和clientWidth用于描述元素内尺寸,是指元素内容+内边距大小,不包括边框(低版本IE下实际包括).外边距.滚动条部分 offsetHeight和off ...

  7. 用reduce装逼 之 多个数组中得出公共子数组,统计数组元素出现次数

    昨天做了一道美团的面试题,要求是给N个数组,找出N个数组的公共子数组. ,,,,]; ,,,,]; ,,,,]; ,,,,]; 以上四个数组,有公共子数组2, 3,7 function main(){ ...

  8. Weekly 10 小结

    A题 模拟 T = int(input()) while T: T -= 1 s = raw_input() n = len(s) res, pre = 0, 0 for i in xrange(1, ...

  9. “本地视频使用flashFXP上传虚拟服务器“的方法

    一.视频转换格式 首先,想要在网页中直接嵌入视频,就得用video标签,而<video>支持的仅有的几种格式中,MP4是兼容性,通用性各方面相对友好的,所以,建议上传之前先转换格式并压缩. ...

  10. 【洛谷】P1888 三角函数

    P1888 三角函数 题目描述 输入一组勾股数a,b,c(a≠b≠c),用分数格式输出其较小锐角的正弦值.(要求约分.) 输入输出格式 输入格式: 一行,包含三个数,即勾股数a,b,c(无大小顺序). ...