window.open (URL, name, features, replace)
参数列表如下:| 特征 | 说明 |
|---|---|
| fullscreen = yes | no | 1 | 0 | 是否使用全屏模式显示浏览器。默认是 no。处于全屏模式的窗口同时处于剧院模式 |
| height = pixels | 窗口文档显示区的高度。单位为像素。 |
| left = pixels | 窗口的 x 坐标。单位为像素。 |
| 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。 |
| toolbar = yes | no | 1 | 0 | 是否显示浏览器的工具栏。默认是 yes。 |
| top = pixels | 窗口的 y 坐标 |
| width = pixels | 窗口的文档显示区的宽度。单位为元素。 |
win = window.open(); //打开新的空白窗口
win.document.write ("<h1>这是新打开的窗口</h1>"); //在新窗口中输出提示信息
win.focus (); //让原窗口获取焦点
win.opener.document.write ("<h1>这是原来窗口</h1>"); //在原窗口中输出提示信息
console.log(win.opener == window); //检测window.opener属性值
win.close;如果在打开窗口内部关闭自身窗口,则应该使用下面的方法。
window.close;使用 window.closed 属性可以检测当前窗口是否关闭,如果关闭则返回 true,否则返回 false。
var url = "c.biancheng.net"; //要打开的网页地址
var features = "height=500, width=800, top=100, left=100, toolbar=no, menubar=no,
scrollbars=no,resizable=no, location=no, status=no"; //设置新窗口的特性
//动态生成一个超链接
document.write('<a href="c.biancheng.net" target="newW">切换到C语言中文网首页</a>');
var me = window.open(url, "newW", featrues); //打开新窗口
setTimeout (function () { //定时器
if (me.closed) {
console.log("创建的窗口已经关闭。");
} else {
me.close();
}
}, 5000); //半秒钟之后关闭该窗口
版权说明:Copyright © 广州松河信息科技有限公司 2005-2025 版权所有 粤ICP备16019765号
广州松河信息科技有限公司 版权所有