Window open() 方法


定义和用法

open() 方法用于打开一个新的浏览器窗口或查找一个已命名的窗口。

语法

window.open(URL,name,specs,replace)
参数 说明
URL 可选。打开指定的页面的URL。如果没有指定URL,打开一个新的空白窗口
name 可选。指定target属性或窗口的名称。支持以下值:

  • _blank - URL加载到一个新的窗口。这是默认
  • _parent - URL加载到父框架
  • _self - URL替换当前页面
  • _top - URL替换任何可加载的框架集
  • name - 窗口名称
specs 可选。一个逗号分隔的项目列表。支持以下值:

channelmode=yes|no|1|0 是否要在影院模式显示 window。默认是没有的。仅限IE浏览器
directories=yes|no|1|0 是否添加目录按钮。默认是肯定的。仅限IE浏览器
fullscreen=yes|no|1|0 浏览器是否显示全屏模式。默认是没有的。在全屏模式下的 window,还必须在影院模式。仅限IE浏览器
height=pixels 窗口的高度。最小.值为100
left=pixels 该窗口的左侧位置
location=yes|no|1|0 是否显示地址字段.默认值是yes
menubar=yes|no|1|0 是否显示菜单栏.默认值是yes
resizable=yes|no|1|0 是否可调整窗口大小.默认值是yes
scrollbars=yes|no|1|0 是否显示滚动条.默认值是yes
status=yes|no|1|0 是否要添加一个状态栏.默认值是yes
titlebar=yes|no|1|0 是否显示标题栏.被忽略,除非调用HTML应用程序或一个值得信赖的对话框.默认值是yes
toolbar=yes|no|1|0 是否显示浏览器工具栏.默认值是yes
top=pixels 窗口顶部的位置.仅限IE浏览器
width=pixels 窗口的宽度.最小.值为100
replace Optional.Specifies规定了装载到窗口的 URL 是在窗口的浏览历史中创建一个新条目,还是替换浏览历史中的当前条目。支持下面的值:

  • true - URL 替换浏览历史中的当前条目。
  • false - URL 在浏览历史中创建新的条目。
function openWindow(url, title, w, h) {
// Fixes dual-screen position Most browsers Firefox
const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width
const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height const left = ((width / 2) - (w / 2)) + dualScreenLeft
const top = ((height / 2) - (h / 2)) + dualScreenTop
const newWindow = window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left) // Puts focus on the newWindow
if (window.focus) {
newWindow.focus()
}
} 点击微信、qq登录打开新窗口

  

 

最新文章

  1. CSS3 :target伪类实现Tab切换效果
  2. MVA Universal Windows Apps系列学习笔记1
  3. 如何为github上的项目添加gif效果图
  4. discuzx3.1中引用 Jquery报错的解决办法
  5. Android控件大全(三)——RecyclerView
  6. struts2与struts1整合,Unable to load configuration. - interceptor-ref ... struts.xml
  7. 第五篇 Getting Started with ORACLE EBS(开始学习ORACLE EBS)
  8. android面试题之一
  9. Java之路——敬JAVA初学者(作者:MoMo)
  10. 简聊iOS支付集成(支付宝和微信支付)
  11. [洛谷P1484] 种树
  12. CentOS7 安装redis4:
  13. Angular基础开始
  14. centos 安装 redis
  15. 20145314郑凯杰《信息安全系统设计基础》第八周复习总结 Part A
  16. P3994 高速公路
  17. UITableViewCell 添加 checkbox 多选
  18. Android实现截图分享qq,微信
  19. Tomcat服务器简介
  20. python 学习分享-paramiko模块

热门文章

  1. java网络通信:netty
  2. Vue中的model
  3. 日常linux命令
  4. visual studio 的 code snippet(代码片段)
  5. oracle ogg 单实例双向-新增表,修改表结构(oracle-oracle
  6. 【算法与数据结构】图的最小生成树 MST - Prim 算法
  7. vue 中滚动div至最底部
  8. 正则表达式——Unicode
  9. 【Python】关于近期爬虫学习的总结
  10. kettle入门大数据管理工具