简体   繁体   中英

Bypassing popup blocker on iOS Safari / any mobile browser

I'm trying to get my web app to open another page (it's triggered by a button click but needs to do some other processing first).

It works everywhere on my desktop. On mobile Chrome, it blocks it as a popup and lets me know that it did so. On mobile Safari, it doesn't even tell me that a popup was blocked. I've tried synchronous AJAX calls like so:

$("#somebutton").click(function() {
  $.ajax({
    url:      myAppURL,
    async:    false,
    dataType: "text",
    success:  function() {
      window.open("http://google.com");
    }
  });
});

And opening the window more directly after the click, then changing its location later:

var myWindow = window.open('')
...
myWindow.location = 'http://google.com'

But that didn't work either (it did on desktop). I'm all out of ideas. Has anybody found a workaround for this?

你可以试试 :

window.open("http://google.com", "_blank");

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