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

不一定打开新窗口,只要有窗口的名称和window.open中第二个参数中的一样就会将这个窗口替换,可以iframe、frame中代替location.href

<iframe name="a"></iframe>
<input type=button onclick="window.open('1.htm','aa','')">
效果同
<input type=button onclick="self.frames['a'].location.href='1.htm'">

示例:

同时弹出两个窗口 ,对源代码稍微改动一下:

function openwin() {
  window.open ("page.html", "newwindow", "height=100, width=100, top=0, left=0,toolbar=no, menubar=no,
     scrollbars=no, resizable=no, location=n o, status=no")
  window.open ("page2.html", "newwindow2", "height=100, width=100, top=1 00, left=100,toolbar=no, menubar=no,
          scrollbars=no, resizable=no, loca tion=no, status=no")
  window.open("http://jxjymember.cdeledu.com/cdel_jxjy_member/groupInfo/view.do?op=goSearchFullName&fullName=" + fullName);
}

为避免弹出的2个窗口覆盖,用top和left控制一下弹出的位置不要相互覆盖即可

注意:2个窗口的name(newwindows和newwindow2)不要相同,或者干脆全部为空。

window.location.href 只能在当前页面打开,window对象的属性

常用形式:

self.location.href;//当前页面打开URL页面

[window.]location.href;//当前页面打开URL页面

this.location.href;//当前页面打开URL页面

location.href;// 当前页面打开URL页面

parent.location.href;//在父页面打开新页面

top.location.href;//在顶层页面打开新页面

注意:

1、如果页面中自定义了frame,那么可将parent、self、top换为自定义frame的名称,效果是在frame窗口打开url地址。

2、window.location.href=window.location.href; 刷新当前页面

window.location.Reload();刷新当前页面,有数据要提交时会提示是否window.location.href=window.location.href;向指定的url提交数据.

3、有时浏览器会屏蔽window.open,避免弹出广告窗口等

4、window.open()是可以在一个网站上打开另外的一个网站的地址 

window.location()是只能在一个网站中打开本网站的网页

href=”#”href=”javascript(0)”

<a
href="#"> 点击链接后,页面会向上滚到页首,# 默认锚点为 #TOP,即刷新页面

<a
href="javascript:void(0)" onClick="window.open()"> 点击链接后,页面不动,只打开链接,需要刷新页面时谨慎使用

<a
href="#" onclick="javascript:return false;"> 作用同上,不同浏览器会有差异。

<a href="####"></a>

<a href="javascript:void(0)"></a>

<a href="javascript:void(null)"></a>

<a href="#" onclick="return false"></a>

windows.open、 window.location.href的更多相关文章

  1. window.location.href和document.location.href、document.URL的区别

    1.document表示的是一个文档对象,window表示的是一个窗口对象,一个窗口下可以有多个文档对象. 所以一个窗口下只有一个window.location.href,但是可能有多个documen ...

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

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

  3. window.location.href/replace/reload()--页面跳转+替换+刷新

    一.最外层top跳转页面,适合用于iframe框架集 top.window.location.href("${pageContext.request.contextPath}/Login_g ...

  4. 5. window.location.href/replace/reload()--页面跳转+替换+刷新

    1.window.location=url; window.location 对象用于获得当前页面的地址 (URL),并把浏览器重定向到新的页面. 一.最外层top跳转页面,适合用于iframe框架集 ...

  5. 2016/2/22 1、DOM的基本概念 2、Window对象操作 3、Windows.history对象 4、Window.location对象 5、Window.status对象

    1.DOM的基本概念 DOM是文档对象模型,这种模型为树模型:文档是指标签文档:对象是指文档中每个元素:模型是指抽象化的东西. 2.Window对象操作 一.属性和方法: 属性(值或者子对象): op ...

  6. 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法

    location.href 和 window.location.href 区别: 1.location.href 可以直接跳转其他地址(不属于本项目) 也可以跳转本项目中的 2.window.loca ...

  7. "window.location.href"、"location.href"是本页面跳转

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

  8. windows.open window.location.href的用法和区别

    window.location.href  只能在当前页面打开,不能用新窗口打开 windows.open("URL","窗口名称","窗口外观设定& ...

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

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

随机推荐

  1. Qt学习笔记-更高级的文本编辑器-完善第一版-gif动画

    现在的浏览器大多都有动作图标,现在我们也为浏览器加上图标. 在网上搜索到了几个ico的图标.现在直接拿来用. 首先创建资源文件. 在工程名上鼠标右键,选择add new 然后再选择 Qt Resour ...

  2. Azure Cost alerts 花费警报

    一,引言 2020已完结,迎来了2021年新的开始.Allen 在新的一年中继续分享自己所学习到的 Azure 技术.本篇文章的内容也不多,也是一个网友遇到的一个问题----- Azure 上有没有花 ...

  3. mysql事务-简介

    mysql事务 问题 概要 storage engine必须支持事务 事务根据隔离级别的不同,不同事务之间有不同的可见性 begin 或者 start transaction, 显式开启事务:comm ...

  4. oracle坚决不挂01(表,索引,视图的创建,修改,删除,查询)

    考试快来了,来篇oracle干货,复习一下(挣扎一下) 废话不多说,开始写! 这篇是数据库对象的有关操作的总结! 数据库对象有熟悉的表,视图,索引,序列,同义词等(这个oracle东西真不少,小声bb ...

  5. 【Software Test】Basic Of ST

    文章目录 Learning Objective Introduction Software Applications Before Software Testing What is testing? ...

  6. kubernets之pod的删除方式

    一 删除单个pod 1  删除指定命名空间的指定名称的pod k delete po kubia-manual -n defaultpod "kubia-manual" delet ...

  7. Sqli - Labs 靶场笔记(一)

    Less - 1: 页面: URL: http://127.0.0.1/sqli-labs-master/Less-1/ 测试: 1.回显正常,说明不是数字型注入, http://127.0.0.1/ ...

  8. oracle RAC和RACOneNode之间的转换

    Convert RAC TO RACOneNode 1.查看资源状态 [grid@rac01 ~]$ crsctl status res -t 从这里看到,数据库的名字叫racdb 2.查看实例 [o ...

  9. kafka(一)入门

    一.消息引擎系统 这类系统引以为豪的消息传递属性,像引擎一样,具备某种能量转换传输的能力 消息引擎系统是一组规范,企业利用这组规范在不同系统之间传递语义准确的消息,实现松耦合的异步式数据传递.通俗地讲 ...

  10. 查看Java的汇编指令

    在IDEA配置VM options,打印汇编指令 -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly windows系统 下载插件 hsdis-amd6 ...