JavaScript关闭当前页面

584 阅读1分钟
/* 关闭当前页面*/
export function closePage() {
  if (navigator.userAgent.indexOf('MSIE') > 0) { // close IE
    if (navigator.userAgent.indexOf('MSIE 6.0') > 0) {
      window.opener = null;
      window.close();
    } else {
      window.open('', '_top');
      window.top.close();
    }
  } else { // close chrome;It is effective when it is only one.
    window.opener = null;
    window.open('', '_self');
    window.close();
  }
}