我不是程序员/开发人员,但坚持修改网站的内容。
说,我有一个网站,我们有10个链接,单击第一个链接后,应该显示一个带有相关视频和“关闭”按钮的框架。用户可以观看该视频并关闭该帧。(我还想将youtube URL作为参数传递给以下功能)
我怎样才能做到这一点?
我尝试下面的HTML
<html>
<body>
<script>
function playme()
{
document.getElementByID('video1').style.visibility=true;
document.getElementByID('video1').src="https://www.youtube.com/watch?v=G2KlPOYu6U8";
}
</script>
<a href="#" id="playvideo" onclick="playme()">Video 1</a></li>
<iframe id="video1" width="520" height="360" frameborder="0" hidden=true></iframe>
但是在这里,iframe没有出现。这个怎么做?
这样的事情会起作用。
/************************************************
**Call playMe() with the video code and the **
**iframe id in the brackets **
************************************************
************************************************
**https://www.youtube.com/watch?v=xLRM0tQmmC8 **
**the code after v= so xLRM0tQmmC8 **
**in this case **
************************************************/
playMe = function (vidCode, id) {
var iframe = document.querySelector('#'+id);
iframe.style.display = "block";
iframe.src = "http://www.youtube.com/embed/" + vidCode;
};
<a href="#" id="playvideo" onclick="playMe('G2KlPOYu6U8','video1')">Video 1</a>
<iframe id="video1" width="520" height="360" frameborder="0" style="display:none;"></iframe>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句