Firefox下實現關閉當前頁面的方法(當然其他瀏覽器也適用)

來源:互聯網
上載者:User

首頁為什麼突出Firefox瀏覽器呢?因為Firefox預設情況下是不能關閉視窗的,有一個情況是這個視窗時通過window.open開啟的。

但是今天這個實踐是來自共同做消保協議閱讀的開發給我說的。具體的實現是:

<button type="button" id="close-win" class="normal-btn" onclick="f_close()">關閉視窗</button><br /><script type="text/javascript"><!--<br /> function f_close(){<br /> window.opener = null;<br /> var wind = window.open('','_self');<br /> wind.close();<br /> }<br />// --><script>

就是這個wind改變了一切。

但是問題是如果直接這樣開啟頁面的話是不能關閉的,前提是這個視窗時通過<a href="#" target="_blank"></a>開啟的才可以,而且一定要是_blank很奇怪。

很簡單明了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.