windows.open、 window.location.href
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的更多相关文章
- window.location.href和document.location.href、document.URL的区别
1.document表示的是一个文档对象,window表示的是一个窗口对象,一个窗口下可以有多个文档对象. 所以一个窗口下只有一个window.location.href,但是可能有多个documen ...
- window.location.href和window.open的几种用法和区别
使用js的同学一定知道js的location.href的作用是什么,但是在js中关于location.href的用法究竟有哪几种,究竟有哪些区别,估计很多人都不知道了. 一.location.href ...
- window.location.href/replace/reload()--页面跳转+替换+刷新
一.最外层top跳转页面,适合用于iframe框架集 top.window.location.href("${pageContext.request.contextPath}/Login_g ...
- 5. window.location.href/replace/reload()--页面跳转+替换+刷新
1.window.location=url; window.location 对象用于获得当前页面的地址 (URL),并把浏览器重定向到新的页面. 一.最外层top跳转页面,适合用于iframe框架集 ...
- 2016/2/22 1、DOM的基本概念 2、Window对象操作 3、Windows.history对象 4、Window.location对象 5、Window.status对象
1.DOM的基本概念 DOM是文档对象模型,这种模型为树模型:文档是指标签文档:对象是指文档中每个元素:模型是指抽象化的东西. 2.Window对象操作 一.属性和方法: 属性(值或者子对象): op ...
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
location.href 和 window.location.href 区别: 1.location.href 可以直接跳转其他地址(不属于本项目) 也可以跳转本项目中的 2.window.loca ...
- "window.location.href"、"location.href"是本页面跳转
"window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...
- windows.open window.location.href的用法和区别
window.location.href 只能在当前页面打开,不能用新窗口打开 windows.open("URL","窗口名称","窗口外观设定& ...
- window.location.href问题,点击,跳转到首页
onClick="window.location.href='./';" 点击,跳转到首页. location.href=url Js中实现跳转 window.location.h ...
随机推荐
- [leetcode]61. Rotate List反转链表k个节点
类似于找链表的后k个节点 不同的是要把前边的接到后边 public ListNode rotateRight(ListNode head, int k) { //特殊情况 if (head==null ...
- 前台生成JSON
方法一 :在后台需要转换String - json let param = new URLSearchParams(); param.append('username', this.username) ...
- sendfile“零拷贝”和mmap内存映射
在学习sendfille之前,我们先来了解一下浏览器访问页面时,后台服务器的大致工作流程. 下图是从用户访问某个页面到页面的显示这几秒钟的时间当中,在后台的整个工作过程. 如上图,黑色箭头所示的过程, ...
- redis加锁的几种实现
redis加锁的几种实现 2017/09/21 1. redis加锁分类 redis能用的的加锁命令分表是INCR.SETNX.SET 2. 第一种锁命令INCR 这种加锁的思路是, key 不存在, ...
- 第13章节 BJROBOT 雷达跟随【ROS全开源阿克曼转向智能网联无人驾驶车】
雷达跟随说明:注意深度摄像头的 USB 延长线,可能会对雷达扫描造成影响, 所以在雷达跟随前,把深度摄像头的 USB 延长线取下.另外雷达跟随范围大概是前方 50cm 和 120°内扫描到的物体都可以 ...
- springboot 不同环境读取不同配置
1. 3个配置文件(更多环境可以建多个): application.properties (公共配置文件) application-dev.properties (开发环境) applicatio ...
- eclipse中把spring源码关联至当前工程
1.下载并导入spring的相关jar包下载对应版本的spring 2.在当前工程中,选择Referenced Libraries,展开后,选择相应的jar包,右击并选择Properties 3. 在 ...
- CountDownLatch/CyclicBarrier/Semaphore 使用过吗
CountDownLatch 让一些线程堵塞直到另一个线程完成一系列操作后才被唤醒.CountDownLatch 主要有两个方法,当一个或多个线程调用 await 方法时,调用线程会被堵塞,其他线程调 ...
- asp.net core 学习笔记
项目整体感知 项目初始化 项目启动流程: Program.cs Microsoft.Extensions.Hosting.Host => CreateHostBuilder().UseStart ...
- CSS_rules
CSS 特性 1)控制灵活,功能强大 元素-->标签 针对html的元素 2)可以设置html元素的属性,与html框架的进行分离 3)执行效率更高 CSS语法 text-indent 文字缩进 ...