How do I open a link in a New Window (iOS)

1 favourites
  • 9 posts
  • As per this thread:

    I've also noticed that iOS treats new window requests from construct exported html5 pages as pop-ups, and as it's been stated iOS safari blocks pop ups by default, and even if it wasn't I'd assume the first pop-up someone got they wouldn't have wanted and so disabled them at that point anyway.

    So I want to know is it possible to fix this issue with a construct update?

    Or is there a fix / workaround that we can use right now?

    Thank you for any assistance!

  • There is nothing Construct 2 can do to work around popup blockers - they are designed to block popup ads that would irritate the user, and anything C2 could do to circumvent it would be done by ads as well.

    Generally the workaround is to only open a window in a user input trigger, such as "on object touched". Browser popup blockers allow popups in user input events, since they are treated as intentional actions by the user.

  • Hi thanks for the reply, I'm not sure if that work around changes anything for me though as I've only tried based on user interaction.


    Ok so I created this to eliminate any other code getting in the way and to test a theory:

    if you load up that link on an iOS device you'll see that the 'NEW' button can open up a new window just fine but the sprite 'NEW' trigger does nothing, is this a bug in the way the sprite works as a trigger?

    (the SAME button and sprite open the link in the same window as expected)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • And I've noticed I can't place a button over a sprite and make it's initial visibility Invisible or even put it under a sprite so there's no hiding a working button


    So with a bit of faffing adjusting the buttons size (which can vary a lot between devices it seems) and adding CSS styles for transparent background and 0 borders, I was able to 'hide' the button over top of the sprite I wanted to open a link in a new window.

    But I'd love to know if that's something that can be fixed in an update it would make C2 life that much easier for what is a small but (for my current project at least) essential element.

  • if you load up that link on an iOS device you'll see that the 'NEW' button can open up a new window just fine but the sprite 'NEW' trigger does nothing, is this a bug in the way the sprite works as a trigger?

    It depends on precisely which events you used, but I can't see which you used without the .capx.

  • well it's the simple touch way of opening a link as far as I'm aware, the capx is here:

  • I tested this on an iPad Air 2. Both options work, but for some reason the Sprite option makes Safari prompt "This page is trying to open a new window" with options to "Allow" or "Block". I think if you block it, it never asks again, so you might think it's failing. However I found a workaround: if you use "on any touch end" followed by "is touching Sprite", it can open the popup without prompting.

    I think this is related to Safari change to do with what counts as a user input event. When iOS 9 came out we had trouble with audio no longer unmuting (Safari needs a user input event to allow audio playback). They blocked "touchstart" from unmuting, but it still worked in "touchend". So we moved unmuting to "touchend" and it fixed it.

    So the three approaches are:

    "On button clicked" - triggers in a "click" event - Safari allows popup

    "On touched Sprite" - triggers in a "touchstart" event - Safari 9+ blocks this

    "On any touch end" - triggers in a "touchend" event - Safari allows this (combined with a "Is touching object" you can get the same effect as "On touched sprite" but triggering at the end of the touch instead of the start)

    So you should be able to work around this already with the "On any touch end" approach.

  • Great!

    Thanks for the work around, it's working just as the button does combining 'On any touch end' with 'is touching Sprite'

    I appreciate you taking the time to help out with this issue and it's interesting to know what the issue was

  • Ashley

    How about keyboard?

    I trying to open a new window when pressed a key and safari blocks it.

    How to fix this?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)