在iOS设备上点击/点按事件不会在iframe中触发

我有一个iframe的实例,包含一个单击处理程序的元素。 iframe包含一个带有播放buttongraphics的video,并附带一个点击事件。 点击事件触发video播放,隐藏自己和console.logs消息说,它已被触发。

这在桌面浏览器上完美运行,当我直接导航到iOS设备上的iframe url时。 但是,embeddediframe时,播放button的点击/点击事件不会被触发。

这里是我的例子的链接:

直接链接到video页面:(按照预期在iOS上工作) http://www.newsryde.com/articlevideo/1085078/

带有video的页面的链接iframed:(不触发点击/点击事件) http://www.newsryde.com/article/1085078/

附加事件的文件/行号在/js/jm/video-player.js行,如下所示:

 els.playButton.on('click tap', function(){ console.log('tapped'); els.playButton.fadeOut(100); els.videoPauseItems.fadeOut(100); jwplayer(container).play(); }); 

embedded的iframe版本的代码不仅不会触发video,而且不会触发console.log或元素淡入淡出。 我可以看到,当点击播放button,该元素闪烁与超快速不透明/反馈状态,我相信是浏览器相关

奇怪的是,当我删除播放button元素。 并让用户直接点击<video>元素。 video播放良好。 我可以理解,如果这是一种方式或其他(没有点击通过,或只是video播放没有触发),但它就好像整个playButton的点击处理程序被忽略

注意:我必须为这个内容使用一个iframe,因为它不能保证它的内容和父页面是在同一个域中(同样,这也阻止了我创build一个到iframe内容的外部控件)

任何帮助将不胜感激。 先谢谢你

编辑1:根据要求,我在示例链接的右上angular添加了一个点击/点击绑定到'N'(我知道这是一个小小的打击框,抱歉)。

 els.videoPauseItems.css('z-index', '600').on('click tap', function(){ console.log('non play button tapped'); }); 

当在iframe点击的时候,我得不到console.log。 但我确实得到浏览器快速灰色闪光反馈。 然而,当检查元素我可以看到,它已经成功地应用.css()调整。 当点击链接而不是在iframe它成功console.log

似乎有人阻止了正常的触摸事件stream的默认操作: touchstarttouchmoveclick 。 这样click事件从不被调用。 可能其他一些脚本通过调用touchstarttouchend事件的事件对象上的preventDefault()或通过从这些事件的事件侦听器返回false来实现此目的。

为了解决这个问题,你可以在事件被阻止之前拦截用户的“点击”。 例如通过使用touchstart事件:

 var ranOnce = false; els.playButton.on('click tap touchstart', function() { // If both click and touchstart events are fired, // then make sure that this function isn't executed twice if click if (ranOnce) return; ranOnce = true; console.log('tapped'); els.playButton.fadeOut(100); els.videoPauseItems.fadeOut(100); jwplayer(container).play(); }); 

我通过我的iPhone上的Safari开发者工具运行这个代码,video播放如期:

在这里输入图像说明