【问题标题】:video popup + text视频弹出+文字
【发布时间】:2023-03-03 16:24:02
【问题描述】:

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

【问题讨论】:

    标签: javascript video text youtube popup


    【解决方案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();
    

    试试这个!

    根据您在 cmets 中的要求:

    <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>​
    

    小提琴:http://jsfiddle.net/BRAQD/

    【讨论】:

    • 我想我做错了什么,因为我现在只能全屏显示我的视频:/
    • 我刚刚尝试过,它对我有用。您使用的是我发布的相同代码吗?
    • 不,只用我的。你能解释一下你得到了什么吗?只有没有示例文本的全屏视频?
    • 您使用哪种浏览器?我创建了一个 Fiddle,它对你有用吗? jsfiddle.net/VSPRf
    • 我使用 safari,有问题吗?在小提琴中,我只看到正文 Hello!
    猜你喜欢
    • 2016-05-08
    • 2019-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多