jquery - 在 WP 中选择更改时更改 YouTube iFrame 源
问题描述
在 WP 模板中,我正在通过 iFrame 加载 YouTube 播放列表。我在它上面有一个选择框,允许用户选择另一个播放列表。这看起来很简单,但我一直遇到浏览器安全问题。
jQuery(document).ready(function() {
$('#channelChooser').change(function() {
$(this).next('iframe').attr('src', this.value);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select name="channelChooser" id="channelChooser">
<option value="https://www.youtube.com/playlistlist=one">One</option>
<option value="https://www.youtube.com/playlist?list=Two">Two</option>
<option value="https://www.youtube.com/playlist?list=Three">Three</option>
</select>
<iframe id="ytplayer" type="text/html" width="720" height="405" src="https://www.youtube.com/embed/?enablejsapi=One&listType=playlist" frameborder="0" allowfullscreen></iframe>
我收到此错误:
拒绝在框架中显示“ https://www.youtube.com/playlist?list=Two ”,因为它将“X-Frame-Options”设置为“sameorigin”。
我只是希望能够在选择时更改 youtube 播放列表,最好没有插件,因为这应该很简单。谢谢!
解决方案
推荐阅读
- html - 将 TD 与 TH 同步
- node.js - 关于 node js 中使用 node-postgres 和渲染页面的回调的问题
- python - 使用 pandas 到 Datetime 的字符串:TypeError:
不能转换为日期时间 - excel - vba将带有工作簿名称和文本的excel工作表保存为PDF
- jquery - 如何清理地图上的 Mapbox-gl 数据
- sql - 如何修复 PL/SQL:ORA-00918:Oracle 中定义不明确的列
- typescript - 在打字稿中从界面创建对象
- kotlin - 运算符重载 Kotlin
- opengl - 使用 OpenGL 执行 YUV 颜色格式的视频合成 - 性能
- c# - WPF Datagrid中的单个单元格背景颜色不是所有的行颜色