all articles

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

2016-09-16 @sunderls

iOS(8.0~8.1.1) safari close() js


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


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.

if (iIOSVersionCannotClose){
        // return to preview url
        location.href = '....'
    }, 2000);
 } some tips, or alert to users , ask them close window manually.

related link