关于javascript:Vue关闭当前浏览器窗口

25次阅读

共计 646 个字符,预计需要花费 2 分钟才能阅读完成。

  1. 传统的 JS 敞开以后窗口
window.opener=null;
window.open('',self);
window.close();
  1. vue 敞开以后窗口
window.opener = null
window.open("about:blank", "_top").close()
  1. 其余
var userAgent = navigator.userAgent;
if (userAgent.indexOf("MSIE") > 0) {if (userAgent.indexOf("MSIE 6.0") > 0) {
      window.opener = null;
      window.close();} else {window.open("","_top");
      window.top.close();}
} else if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") != -1) {
    window.location.href = "about:blank"; // 火狐默认状态非 window.open 的页面 window.close 是有效的
    //window.history.go(-2);
} else {
    window.opener = null;
    window.open("about:blank", "_self");
    window.close();}

4. 阐明

_blank - URL 加载到一个新的窗口 (默认)
_parent - URL 加载到父框架
_self - URL 替换以后页面
_top - URL 替换任何可加载的框架集 

正文完
 0