在 IE8 中通过 javascript 删除嵌入的 YouTube 视频时出现黑屏
我使用此代码让用户在我正在构建的网站上嵌入 youtube 视频:
function BuildYoutubePlayer(youtubeVideoId, width, height) {
youtubePlayer = "<iframe ";
youtubePlayer += "width=\"" + width + "\" ";
youtubePlayer += "height=\"" + height + "\" ";
youtubePlayer += "src=\"http://www.youtube.com/embed/" + youtubeVideoId + "\"&wmode=transparent ";
youtubePlayer += "frameborder=\"0\" allowfullscreen>";
youtubePlayer += "</iframe>";
return youtubePlayer;
}
此嵌入将作为灯箱弹出窗口位于图层中,当用户关闭此弹出窗口时,视频将从 html 中删除,但我得到的是黑色全屏在 IE8 上,我找不到任何原因,我尝试嵌入 YouTube 视频并将其删除,效果很好,所以肯定我遗漏了一些东西。请指教。
I use this code to let users embed youtube videos on a website i am building:
function BuildYoutubePlayer(youtubeVideoId, width, height) {
youtubePlayer = "<iframe ";
youtubePlayer += "width=\"" + width + "\" ";
youtubePlayer += "height=\"" + height + "\" ";
youtubePlayer += "src=\"http://www.youtube.com/embed/" + youtubeVideoId + "\"&wmode=transparent ";
youtubePlayer += "frameborder=\"0\" allowfullscreen>";
youtubePlayer += "</iframe>";
return youtubePlayer;
}
This embed will be in a layer as lightbox popup, when the user closes this popup, the video removed from the html, but I get a black full screen just on IE8, I can't find any reason, I tried embedding youtube video and removing it, and it worked fine, so sure I am missing something. please advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我解决了这个问题,方法是先隐藏 iFrame,然后再删除它,同时删除父弹出窗口。
所以我说
$('iframe').hide();
然后$('myContainerPopup').remove();
我在 IE8 和 YouTube 视频上遇到了这个问题,没有在 IE7 上进行测试,但在所有其他浏览器上一切正常。
I solved that by hiding the iFrame before removing it while removing the parent popup.
So I say
$('iframe').hide();
then$('myContainerPopup').remove();
I faced this problem just on IE8 and youtube videos, didn't test on IE7 but on all other browsers things were working fine.
我使用这段代码:
});
I use this code:
});