【问题标题】:IOS Safari window open on touchstart or touchendIOS Safari 窗口在 touchstart 或 touchend 上打开
【发布时间】:2015-12-20 11:01:56
【问题描述】:

此代码适用于大多数 android/chrome 移动浏览器:

document.body.addEventListener('touchend', function (e) {
    //alert(1);
    window.open("http://test.com");
}, false)

但它在 iOS/Safari (tested with iPhone OS 9_2, AppleWebKit 601.1.46, Safari/601.1). 中不起作用

是否有任何解决方法可以显示包含此事件的新窗口/标签?

"alert(1)" 工作正常,所以我想事件正在正常触发。

谢谢。

【问题讨论】:

    标签: javascript ios mobile-safari window.open touchstart


    【解决方案1】:

    似乎从 iOS >= 9.0 开始,您不能再在“touchstart”事件处理函数中使用 window.open。您可以改用点击。

    在 iOS 8.x 中,您仍然可以在“touchstart”事件处理函数中使用 window.open 打开页面

    【讨论】:

      猜你喜欢
      • 2012-06-05
      • 2020-04-22
      • 1970-01-01
      • 2012-12-05
      • 1970-01-01
      • 1970-01-01
      • 2012-05-11
      • 2014-05-16
      • 1970-01-01
      相关资源
      最近更新 更多