0
点赞
收藏
分享

微信扫一扫

ASP.NET关闭当前页(兼容IE、谷歌、火狐等主流浏览器)



asp.net code:

ClientScript.RegisterStartupScript(Page.GetType(), "", "<script language=javascript>CloseWebPage();</script>");

js code:

优化版(当window.close()无效时,跳转空页面)

window.opener = null;
window.open('', '_self', '');
window.close();
window.location.href = 'about:blank ';


(原版参考文章

<script type="text/javascript">  
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 ';
//window.history.go(-2);
}
else {
window.opener = null;
window.open('', '_self', '');
window.close();
}
}
</script>



举报

相关推荐

0 条评论