本文摘自PHP中文网,作者藏色散人,侵删。
javascript关闭浏览器的方法:1、通过“ function CloseWebPage(){...}”方法实现关闭浏览器网页;2、通过“open(location, '_self').close();”方法关闭浏览器网页。

本文操作环境:windows7系统、javascript1.8.5版、Dell G3电脑。
js实现关闭浏览器
兼容所有浏览器网页关闭方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <button id= "exitSystem" onclick= "CloseWebPage()" >关闭</button>
<script>
function CloseWebPage() {
if (navigator.userAgent.indexOf( "MSIE" ) > 0) {
if (navigator.userAgent.indexOf( "MSIE 6.0" ) > 0) {
window.opener = null; window.close();
}
else {
window.open( '' , '_top' ); window.top.close();
}
}
else if (navigator.userAgent.indexOf( "Firefox" ) > 0) {
window.location.href = 'about:blank ' ;
}
else {
window.opener = null;
window.open( '' , '_self' , '' );
window.close();
}
}
</script>
|
阅读剩余部分
相关阅读 >>
如何使用css设计出一个表单页面(附示例)
利用jssdk在网页中获取地理位置
实例详解javascript中split字符串分割函数
javascript怎么停止函数执行
object.fromentries和object.entries的使用
学javascript要什么基础?
深入了解javascript中的null
html页面自动清理js、css文件的缓存(自动添加版本号)_html/xhtml_网页制作
你不太了解的json
javascript失去焦点如何设置
更多相关阅读请进入《javascript》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » javascript怎么关闭浏览器