原文:https://blog.csdn.net/qq_41176306/article/details/119209585
当页面中有iframe时,想在主页面调用iframe中的方法,可以用contentWindow属性。但具体用时还有一点要注意,就是必须等页面加载完成才可以,否则会报错找不到函数。
setTimeout (f,0)的作用很简单,就是为了把f放到运行队列的最后去执行。 就是说,无论setTimeout (f,0)写在哪,都可以保证在队列的最后执行,因为它是异步操作
$(document).off('change', '#timemark').
on('change', '#timemark', function (event) {
console.log('打印参数time');
if($(this).is(':checked')){
console.log('iframeWindow的方法');
setTimeout(function(){
const iframeWindow=document.getElementById("task-content-iframe");
iframeWindow.contentWindow.window.currentTime();
//iframe需加载完,才可调用
},0)
}else{
$('#currentVideoTime').val('0:0:1')
}
}); | 留言与评论(共有 0 条评论) “” |