【发布时间】:2017-04-04 20:06:16
【问题描述】:
我无法将 youtube 视频放在弹出窗口中。
问题是插入那个。我不能只用<iframe>。它没有显示视频:(。我将<iframe> 放入一个 div 中但它不起作用。我将向您展示我的脚本、css 样式和 html。
我想做一些像你点击弹出窗口的东西,在这个弹出窗口中显示的是 YouTube 视频。
HTML
<div id="popupBox_1">
<div class="popupBoxWrapper">
<div class="popupBoxContent">
<h3>Popup 1</h3>
<embed width="420" height="315" src="https://www.youtube.com/watch?v=LRblJyq_4Ko">
</div>
</div>
</div>
我也尝试了使用方法,但它也不起作用:(。
JavaScript
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
window.onclick = function(event) {
if (event.target == popupBox_1) {
popupBox_1.style.display = "none";
}
if (event.target == popupBox_2) {
popupBox_2.style.display = "none";
}
if (event.target == popupBox_3) {
popupBox_3.style.display = "none";
}
if (event.target == popupBox_4) {
popupBox_4.style.display = "none";
}
if (event.target == popupBox_5) {
popupBox_5.style.display = "none";
}
if (event.target == popupBox_6) {
popupBox_6.style.display = "none";
}
if (event.target == popupBox_7) {
popupBox_7.style.display = "none";
}
if (event.target == popupBox_8) {
popupBox_8.style.display = "none";
}
if (event.target == popupBox_9) {
popupBox_9.style.display = "none";
}
}
CSS
#popupBox_1 {
top: 0; left: 0; position: fixed; width: 100%; height: 120%;
background-color: rgba(0,0,0,0.7); display: none; border-radius: 10px !important;}
【问题讨论】:
-
你在哪里打电话
toggle_visibility,popupBox_*是在哪里定义的?是否有任何控制台错误? (F12 -> 控制台) -
这不是必需的,我用它来点击,当你点击这个弹出窗口时会显示。
标签: javascript html css youtube