简体   繁体   中英

window.close() doesn't work on windows phone IE

window.close() doesn't work on windows phone with IE.

The tab is opened with :target="_blank" and i try to close it with the following code:

<div onclick="window.close();"></div>

I tried on IE 11 on windows 8.1 and it worked, without errors, after confirm message.

I tried on Lumia 925, on windows phone emulator, and it didn't work. The page remains open.

I made the following test page:

http://www.qualcosadafare.it/test/test/anp.php

Have any idea?

Thanks.

Mobile IE only uses one tab. When you use target="_blank" you actually aren't opening a new tab, you are opening it in the current tab. There isn't much you can do about this.

Probably the best thing you might be able to do is detect if the user is using IE:

function msieversion() {
        var ua = window.navigator.userAgent;
        var msie = ua.indexOf("MSIE ");
        if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
            return true
        else
            return false
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM