zoukankan      html  css  js  c++  java
  • JS关闭当前窗口

     1  function closePage() {
     2         if (navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Chrome") != -1) {
     3             window.location.href = "about:blank";
     4             window.close();
     5         } else {
     6             window.opener = null;
     7             window.open("", "_self");
     8             window.close();
     9         }
    10     }
    11 
    12 
    13     $('#login-out').on('click', function () {
    14         $.ajax({
    15             type: 'post',
    16             url: '/Account/Logout',
    17             data: { login_from: 'agent' },
    18             success: (res) => {
    19                 // console.log("退出成功");
    20                 // window.location.href = "/Account/Login";
    21                 var hideThirdAgentId = $('#hide-ThirdAgentId').val();
    22                 if (hideThirdAgentId) {
    23                     window.location.href = "/Account/Login";
    24                 } else {
    25                     //window.opener = null;
    26                     //window.open('', '_self');
    27                     //window.close();
    28                     closePage();
    29                 }
    30 
    31             }
    32         });
    33 
    34     });

    谷歌浏览器和火狐浏览器存在兼容,不能使用下面三行代码进行常规浏览器关闭,会提示

    Scripts may close only the windows that were opened by it  (脚本只能关闭它所打开的窗口)

    其他浏览器可以正常关闭

    window.opener = null;
    window.open('', '_self');
    window.close();
  • 相关阅读:
    routing路由模式
    MQ的订阅模式
    RabbitMq中的消息应答与持久化
    work工作消息队列Round-robin与Fair dispatch
    040 关于hive元数据的解析
    simple简单消息队列
    用户设置与virtual host配置
    Mq的介绍
    字典
    元组Tuple
  • 原文地址:https://www.cnblogs.com/WQ1992/p/12586539.html
Copyright © 2011-2022 走看看