我想在跨域 iframe 中触发点击事件。
对于视频嵌入,我们使用图像作为这些 iframe 的封面。单击图像时,将加载 iframe。这个视频嵌入没有可以使用的自动播放功能,所以我们需要点击加载的嵌入来启动视频。
我们要单击图像,加载视频嵌入(iframe)并使用 jQuery 再次单击该 iframe。
小智 0
window.focus();//force focus on the currenct window;
window.addEventListener('blur', function(e){
if(document.activeElement == document.getElementById('your_iframe_id'))
{
//do your stuff
}
});
$('your_iframe_id').mouseleave(function(){
window.focus();
});// double check when mouse out of iframe
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5016 次 |
| 最近记录: |