我公司的專案是只用IE瀏覽器的,用下面的代碼就可以關閉。
window.opener=null;
window.open('','_self');
window.close();
家里只有chrome,Edge瀏覽器,用上面的方法都不好用。
錯誤資訊都是“Scripts may close only the windows that were opened by them"
如果把代碼改一下:
window.opener=null;
window.open('about:blank','_self');
window.close();
兩個瀏覽器都會關閉當前頁面,不過留了一個about:blank頁面在哪里。
請問怎么才能在chrome,Edge中完美的關閉一個頁面呢?
uj5u.com熱心網友回復:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
function closewind(){
window.opener=null;
window.open('','_self');
window.close();
}
</script>
</head>
<body>
<button onclick="closewind()">點擊</button>
</body>
</html>
我用你那個代碼寫的這個 不知道是不是符合你的實際呼叫方式
Chrome和360是好用的,Firefox不行
Chrome 版本 84.0.4147.135(正式版本) (64 位)
uj5u.com熱心網友回復:
window.close(); 或者this.remove(); 或者this.hide();轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/12146.html
標籤:JavaScript
上一篇:[提問]Vue+axios+echarts+element專案搭建相關問題
下一篇:瀏覽器,cookie的路徑問題
