22

I am trying to open new tab via Javascript using window.open(), then using window.close() to close, but it seems window.close() doesn't work in safari( iOS 8 GM seed). Here is the code:

A.html:

<button onclick="window.open('./B.html'); return false;">Open B</button>

B.html:

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

I tried several ways like: setTimeout, window.open() then close, but doesn't help.

Is there any workaround for this situation?

4
  • 1
    Yepp. This sucks big time! It have not been fixed in the released version of iOS 8.0, and I guess this problem will not be fixed in any upcoming version of iOS 8 either. So we will simply have to live with it. Apple is currently in the process of destroying the web.
    – Kalle
    Sep 17, 2014 at 20:54
  • @Pinal, how is that a duplicate? Looks completely unrelated
    – krukid
    Sep 25, 2014 at 11:46
  • Yes, I wanted to close another. Sorry.
    – Alex
    Sep 25, 2014 at 11:49
  • I updated to iOS v9.3.5 and it started to work Mar 13, 2018 at 16:47

1 Answer 1

19

There isn't a workaround.

I added a message in our web pages. 'Please close this window if it does not close automatically.'

There is a forum about this issue. https://devforums.apple.com/message/1044445

14
  • 1
    It might be helpful to include the gist of the forum comments on this issue. The Apple dev forums are behind a paywall.
    – aychedee
    Sep 24, 2014 at 10:28
  • Posts from that forum: "To clarify, if it is a known bug is there a reference number I can find to study why it is so? From my limited Google search, Apple had identical problem with initial iOS 7 release then somewhere along the way it got fixed. It truly is very frustrating to see no workaround out there." Sep 26, 2014 at 14:04
  • 2
    "iOS 8.0.2 still does not fix this issue. :(" Sep 26, 2014 at 14:05
  • 2
    This bug has not been fixed in iOS 8.1 Beta. My guess is that we'll have to live with this bug for some time forward.
    – Kalle
    Sep 30, 2014 at 12:06
  • 8
    iOS 8.1.1 fixed this issue. Thanks a lot! Nov 18, 2014 at 10:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.