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. PAT甲级——A1047 Student List for Course

    Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course ...

  2. 【DM8168学习笔记5】EZSDK目录结构

    EZSDK5.02的目录结构与之前的版本不同,之前的版本各个组件都放在/ezsdk目录下,5.02做了整合. 之前版本:(图片摘自:3.DM816x_1-day_Workshop-Getting_St ...

  3. webServices学习四(---WebService监听工具)

    之前我们使用过HttpWatch获取的HTTP的调用过程,并获得了HTTP的请求头及其他请求的详细信息. 既然WebServie也是通过HTTP进行通信的,能不使用HTTPWatch来获取它的请求过程 ...

  4. 跟我一起了解koa(二)

    koa中路由动态传值 1.路由 路由(Routing)是由一个 URI(或者叫路径)和一个特定的 HTTP 方法(GET.POST 等) 组成的,涉及到应用如何响应客户端对某个网站节点的访问. 通俗的 ...

  5. springcloud的服务提供者与服务消费者

    1.说明 springcloud中由服务消费者调用服务提供者一共有两种方法rest和feign 2.feign (1)使用feign的方式进行服务调,搭建服务提供者. 创建一个web项目(服务提供者) ...

  6. 微服务开源生态报告 No.10

    「微服务开源生态报告」,汇集各个开源项目近期的社区动态,帮助开发者们更高效的了解到各开源项目的最新进展. 社区动态包括,但不限于:版本发布.人员动态.项目动态和规划.培训和活动. 非常欢迎国内其他微服 ...

  7. 接口--全局异常配置--异常处理handle自定义配置

    在重写了异常处理的handle类之后需要配置配置文件中handle的路径:

  8. CesiumLab V1.3 新功能 MAX场景处理(免费Cesium处理工具集)

    每次到写文章的时候就很高兴,意味着又有重大功能更新了,也意味着10多天昏天黑地的闭关日子暂时结束了. 依照惯例,先放图   小范围精模型cesium加载效果   大范围白模cesium加载效果     ...

  9. 揭秘webdriver实现原理【转】

    通过研究selenium-webdriver的源码,笔者发现其实webdriver的实现原理并不高深莫测无法揣度.在这里以webdriver ruby binding的firefox-webdrive ...

  10. oracle常用的时间格式转换

    1:取得当前日期是本月的第几周  select to_char(sysdate,'YYYYMMDD W HH24:MI:SS') from dual; TO_CHAR(SYSDATE,'YY') se ...