我有一个 YouTube 视频出现在 jquery 对话框中,因此如果在对话框窗口关闭时正在播放它,它将在幕后继续播放。
我所做的结果是在关闭窗口时销毁它:
$("#gallery_reel").dialog({
autoOpen: false,
width: 540,
close: function() {
$(this).dialog('destroy');
}
});
但是一旦对话框被销毁,除非我刷新页面,否则它不会再次打开。如何重新打开对话框?
最佳答案
我建议只使用 close 函数来停止 youtube video ,但如果您坚持其他,而不是销毁,请尝试以下操作:
Non-preferred (will copy html into a newly emptied dialog)
$("#gallery_reel").dialog({
autoOpen: false,
width: 540,
close: function() {
var inrHTML = $(this).html();
$(this).empty().html(inrHTML);
}
});
Should be better Method (Based on the thought that most "embeded youtube" vids are in Iframes, i think
$("#gallery_reel").dialog({
autoOpen: false,
width: 540,
close: function() {
$(this).find("iframe").get(0).stopVideo();
}
});
关于javascript - 销毁 Jquery 对话框后打开它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13035908/