SOURCE

console 命令行工具 X clear

                    
>
console
var isIOS = /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent);
    var isAndroid = /(Android)/i.test(navigator.userAgent);

    function closeWin() {
      alert(navigator.userAgent);
      if (navigator.userAgent.indexOf("MSIE") > -1) {
        if (navigator.userAgent.indexOf("MSIE 6.0") > -1) {
          window.opener = null;
          window.close();
        } else {
          window.open('', '_top');
          window.top.close();
        }
      }
      else if (isIOS ){
        alert(11);
        window.location.href = 'about:blank ';
      }else if( navigator.userAgent.indexOf("Firefox") > -1 || navigator.userAgent.indexOf("Chrome") > -1 || navigator.userAgent.indexOf("Safari") > -1) {
        window.location.href = 'about:blank ';
      } else {
        window.opener = null;
        window.open('', '_self', '');
        window.close();
      }
    }
<a href="javascript:closeWin();">关闭页面</a>
<div id="str"></div>