gpt4 book ai didi

javascript - IOS Safari 窗口在 touchstart 或 touchend 上打开

转载 作者:行者123 更新时间:2023-11-28 06:34:55 26 4
gpt4 key购买 nike

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

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

但它无法在 iOS/Safari 中运行(使用 iPhone OS 9_2、AppleWebKit 601.1.46、Safari/601.1 进行测试)。

是否有任何解决方法可以通过此事件显示新窗口/选项卡?

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

谢谢。

最佳答案

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

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

关于javascript - IOS Safari 窗口在 touchstart 或 touchend 上打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34380281/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com