我正在使用脚本在弹出窗口中播放我的YouTube视频。是否可以更改此设置以便我可以在弹出窗口中播放视频,但在下面添加5行文本作为视频信息?
<script type="text/javascript">
//<![CDATA[
function showPopup(url) {
newwindow=window.open(url,'name','height=315,width=560,top=200,left=300,resizable');
newwindow.focus();
}
//]]>
</script>
答案 0 :(得分:1)
var win = window.open("", "win", "width=500,height=600"); // a window object
win.document.open("text/html", "replace");
win.document.write('<iframe width="420" height="315" src="http://www.youtube.com/embed/bKkESJ1abRA" frameborder="0" allowfullscreen></iframe><p>Your text</p><p>Hey, moar text :D</p>');
win.document.close();
win.focus();
试试这个!
在评论中提出请求后:
<html>
<head>
<script>
function openWindow(url,id){
var win = window.open("", "win", "width=500,height=600"); // a window object
var myText = document.getElementById(id).innerHTML;
win.document.open("text/html", "replace");
win.document.write('<iframe width="420" height="315" src="'+url+'" frameborder="0" allowfullscreen></iframe>'+myText);
win.document.close();
}
</script>
</head>
<body>
<img src="asd.jpg" onclick="openWindow('http://www.youtube.com/embed/bKkESJ1abRA','div1')">
<img src="dsa.jpg" onclick="openWindow('http://www.youtube.com/embed/bKkESJ1abRA','div2')">
<div style="display: none" id="div1">
<p>My text 1</p>
</div>
<div style="display: none" id="div2">
<p>My text 2</p>
</div>
</body>
</html>