all articles

window.close() not working on iOS8.0 8.1

2016-09-16 @sunderls

iOS(8.0~8.1.1) safari close() js

desc

from iOS8.0, window open by js cannot be closed by window.close(). This is a bug, and is fixed at iOS8.1.1.

workaround

1.avoid opening new window by js on iOS(8.0 ~ 8.1.1), and use page redirect.

2.fallback to page redirect in new window, after 2 sconds. though this will cause one page to be opended two times.

window.close();
if (iIOSVersionCannotClose){
    setTimeout(function(){
        // return to preview url
        location.href = '....'
    }, 2000);
 }

3.show some tips, or alert to users , ask them close window manually.

related link

http://webdev.jp.net/ios8-window-close-bug/