我们有一个带有 YouTube 视频模式的页面,但点击视频时出现以下错误:
Uncaught TypeError: $(...).on is not a function
at HTMLAnchorElement.<anonymous> ({bfd8100b-7a47-4b28-9e6d-e26f4a7d9ed9}_ytplayer001.js:747)
at HTMLAnchorElement.handle (jquery.tools.min.js:75)
at HTMLAnchorElement.o (jquery.tools.min.js:69)
视频模式按预期弹出,但显示“雪花”屏幕,并且视频播放器 Controller 无响应。我认为这可能与冲突问题有关并进行了更改
}(jQuery));
至
}(jQuery.noConflict()));
但问题仍然存在。我想我错过了一些非常明显的东西,但经过几天的故障排除后,仍然无法弄清楚。
更新 - 当我删除 jquery.tools.min.js 文件时,视频会播放,但表单验证停止工作。因此 jquery.tools.min.js 文件与 YouTube 视频存在冲突。
更新 - 用当前版本替换 jquery.tools.min.js 修复了视频和表单验证的问题。剩下的就是弄清楚为什么视频模式上的关闭按钮不起作用。打开视频模态时,出现以下错误:
TypeError: $(...).on is not a function
$('.vid-close').on('click', function () {
最佳答案
更改此:
$(document).on('click', '.vid-close', function () {
$('#vidlightbox').hide();
if (videosource == "youtube") {
$('#vidcontent').empty();
att.entbus.ytPlayer.stopAll();
} else {
if (jwplayer('jwPlayer') != null) {
try {
jwplayer('jwPlayer').remove();
} catch(err) {}
}
}
});
对此:
$('.vid-close').on('click', function () {
$('#vidlightbox').hide();
if (videosource == "youtube") {
$('#vidcontent').empty();
att.entbus.ytPlayer.stopAll();
} else {
if (jwplayer('jwPlayer') != null) {
try {
jwplayer('jwPlayer').remove();
} catch(err) {}
}
}
});
关于javascript - YouTube 模态静态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42440551/