Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 视频弹出窗口+;文本_Javascript_Video_Text_Youtube_Popup - Fatal编程技术网

Javascript 视频弹出窗口+;文本

Javascript 视频弹出窗口+;文本,javascript,video,text,youtube,popup,Javascript,Video,Text,Youtube,Popup,我正在使用脚本在弹出窗口中播放我的youtube视频。是否可以更改此设置,以便我可以在弹出窗口中播放视频,但在下面添加5行文本作为有关视频的信息 <script type="text/javascript"> //<![CDATA[ function showPopup(url) { newwindow=window.open(url,'name','height=315,width=560,top=200,left=300,resizable');

我正在使用脚本在弹出窗口中播放我的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>

//
var-win=window.open(“,“win”,“width=500,height=600”);//窗口对象
打开(“文本/html”、“替换”);
win.document.write(“你的文本

嘿,moar文本:D

”); 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>​

函数openWindow(url,id){
var win=window.open(“,“win”,“width=500,height=600”);//窗口对象
var myText=document.getElementById(id).innerHTML;
打开(“文本/html”、“替换”);
win.document.write(“”+myText);
win.document.close();
}
我的课文1

我的课文2


Fiddle:

我想我做错了什么,因为我现在只能看到我的视频的全屏:/I我刚刚试过,它对我很有效。你用的代码和我贴的一样吗?不,用我的就行了。你能解释清楚你得到了什么吗?只有全屏视频,没有示例文本?您使用哪种浏览器?我做了一把小提琴,对你有用吗?我用safari,有问题吗?在小提琴中,我只看到身体的文字“你好!”!
<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>​