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. MacBook安装QF9700网卡驱动

    HOW TO USE A GENERIC USB ETHERNET ADAPTER QF9700 ON MAC OS X  20 February 2016  macOS  Zahid Mahmood ...

  2. 读书笔记--iBATIS in Action 目录

    1.iBATIS的理念 2.iBATIS是什么 3.安装和配置iBATIS 4.使用以映射语句 5.执行非查询语句 6.使用高级查询技术 7.事务 8.使用动态SQL 9.使用高速缓存提高性能 10. ...

  3. java并发系列(六)-----Java并发:volatile关键字解析

    在 Java 并发编程中,要想使并发程序能够正确地执行,必须要保证三条原则,即:原子性.可见性和有序性.只要有一条原则没有被保证,就有可能会导致程序运行不正确.volatile关键字 被用来保证可见性 ...

  4. 配置 CentOS 7 的网络,及重命名网卡名

    Centos 安装时应配置网络,如果当时没配置好,则装完系统后, 也可通过修改配置文件并重启网络服务进行配置. 说明:CentOS 7.0默认安装好之后是没有自动开启网络连接的! cd /etc/sy ...

  5. C# params 用法简介

    params 是C#的关键字, params主要是在声明方法时参数类型或者个数不确定时使用,关于params 参数数组,需掌握以下几点: 一.参数数组必须是一维数组 二.不允许将params修饰符与r ...

  6. IO流6 --- FileReader中使用read(char[] cbuf)读入数据 --- 技术搬运工(尚硅谷)

    FileReader 字符输入流 @Test public void test2(){ File file = new File("hello.txt"); FileReader ...

  7. Boost.Asio基础

    http://www.voidcn.com/article/p-exkmmuyn-po.html http://www.voidcn.com/article/p-xnxiwkrf-po.html ht ...

  8. MySQL数据库起步 linux安装(更新中...)

    卸载mysql! [root@localhost usr]# yum remove mysql mysql-server mysql-libs compat-mysql51 [root@localho ...

  9. day36 09-Hibernate中的事务:事务处理

    什么是丢失更新呢?有一条数据你查出来了,查出来之后有一个事务A和一个事务B也都过来操作同一个记录.A拿到这条记录之后可能改它的某一个值了,B拿到这条记录之后改它的另外一个值.这个时候A事务提交已经提交 ...

  10. 洛谷P1967 [NOIP2013提高组Day1T2]货车运输

    P1967 货车运输 题目描述 A 国有 n 座城市,编号从 1 到 n,城市之间有 m 条双向道路.每一条道路对车辆都有重量限制,简称限重.现在有 q 辆货车在运输货物, 司机们想知道每辆车在不超过 ...