Home > Web Front-end > JS Tutorial > body text

不提示直接关闭网页窗口的JS示例代码_javascript技巧

WBOY
Release: 2016-05-16 17:08:51
Original
1490 people have browsed it

在IE7、IE8中,使用JavaScript提供的close()方法都可以关闭当前窗口或标签,但都提示讨厌的对话框,找了下代码,终于可以无提示直接关闭了。

JavaScript代码

复制代码 代码如下:

function CloseWin()     
{      
window.opener=null;     
window.open('','_self');     
window.close();      
}   

实例:

XML/HTML代码
1.

对于父窗口打开子窗口,点击子窗口关闭,同时关闭父窗口的操作:
var windowParent = window.opener;
windowParent.opener = null;
windowParent.open('', '_self');
windowParent.close();

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!