javascript - 拒绝在 iframe 中显示 youtube 视频

标签 javascript jquery html twitter-bootstrap youtube

当我打开 #myModal 时,模态出现并且我的视频可以播放,但是,当我点击我的 #myModal2 时,模态出现但视频没有显示...

我错过了什么?

<div class="list-group">
    <h3 class="bg-ownmade paddingAll removeMargin">
        <span class="fa fa-book" aria-hidden="true"></span> Webbhistoria
    </h3>
    <a href="#" class="list-group-item" data-toggle="modal" data-target="#myModal" 
        data-keyboard="true"><span class="fa fa-film"></span> ABC</a>
    <!-- Modal -->
    <div class="modal fade" id="myModal" role="dialog" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">
                         &times;</button>
                    <h4 class="modal-title">Instruktionsvideo om...</h4>
                </div>
                <div class="modal-body">
                    <iframe width="100%" height="500px" 
                        src="https://www.youtube.com/embed/db-7J5OaSag" 
                        frameborder="0" allowfullscreen></iframe>
                    <p>Bla bla bla</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" 
                        data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
    <a href="#" class="list-group-item" data-toggle="modal" 
        data-target="#myModal2" data-keyboard="true">
            <span class="fa fa-film"></span> ABC
    </a>
    <!-- Modal -->
    <div class="modal fade" id="myModal2" role="dialog" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" 
                        data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Instruktionsvideo om...</h4>
                </div>
                <div class="modal-body">
                    <iframe width="100%" height="500px" 
                        src="https://www.youtube.com/watch?v=IsXEVQRaTX8" 
                        frameborder="0" allowfullscreen></iframe>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" 
                        data-dismiss="modal">Close</button>
                </div>
            </div>

        </div>
    </div>
</div>

最佳答案

改变:

src="https://www.youtube.com/watch?v=IsXEVQRaTX8"

收件人:

src="https://www.youtube.com/embed/IsXEVQRaTX8"

出于安全原因请求被拒绝:

Refused to display 'https://www.youtube.com/watch?v=IsXEVQRaTX8' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

使用YouTube's Embed URL

关于javascript - 拒绝在 iframe 中显示 youtube 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37341608/

相关文章:

javascript - Bootstrap popover destroy and recreate 仅每秒钟工作一次

javascript - 如何在用户代理检测后使用 jquery 替换 css

javascript - 如何知道哪个 $.ajax promise 已解决?

html - 防止表扩展到父级之外

javascript - 用于复杂 Web 项目的单元测试框架/工具

javascript - 如何拉伸(stretch)整个窗口的背景?

jquery - 将多个 jquery 循环与 ipad 的 touchwipe(滑动)事件结合使用

jquery - 如何设置响应移动的html表格

javascript使用纯JS根据另一个多选框中的选择禁用多选

php - 通过javascript将变量传递给PHP