Youtube iframe API调用以播放视频/pauseVideo don'我不在IE8工作
Youtube iframe API calls to playVideo/pauseVideo don't work in IE8
示例代码:
<div id="ytplayer"></div>
<a id="start" href="#">start</a>
<script>
// Load the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// Replace the 'ytplayer' element with an <iframe> and
// YouTube player after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('ytplayer', {
height: '390',
width: '640',
videoId: 'U6oKcAXiVlo',
playerVars: { 'autoplay': 0, 'controls': 0, 'showinfo': 0 },
});
}
document.getElementById("start").addEventListener("click", function () {
player.playVideo();
});
</script>
再现性测试用例:http://fiddle.jshell.net/3fpusLm5/show/
播放器变量在作用域中。但是对对象上应该可用的方法(例如playVideo、pauseVideo)的调用不起作用。上面写着Object does not support this property or method
。
该代码适用于大多数现代浏览器。我确信玩家已经上膛了。我已经测试了onReady回调,并尝试等待30秒。
实际上,IE已经给出了答案。我在IE8模式下测试了IE9上的链接,并收到了错误
对象不支持属性或方法"addEventListener"
实际上,IE8只支持attachEvent。
您可以检查此选项是否存在并设置正确的侦听器,也可以添加一个将为您应用此选项的外部脚本,如addEventListener Polyfill。
相关文章:
- IE8更改文本区域上的事件侦听器不工作
- window.onbeforeunload在IE8中不触发(在Firefox,Chrome和Safari中工作正常)
- $('body').on('blur')在IE8中工作不好
- window.location重定向没有'我不在IE8上工作
- addEventListener没有'不能在IE中工作(在IE8中测试)
- Requirejs和主干应用程序,不能在IE8中工作
- 无法在 IE 9 中传递此运算符的值,而它在 IE7 和 IE8 中工作正常
- Request.UrlReferrer在IE8中无法正常工作,并且工作正常IE9
- 不触发 OnClick 事件 IE8,但在 Firefox 中工作正常
- 如何优化我的jQuery以始终在IE8中工作,目前它被击中和错过
- 获取尾随逗号(在JavaScript中)在IE7 / IE8中工作
- FormData ajax 上传 IE8 -> 替代品及其工作原理
- jquery设置隐藏的输入值在IE7和IE8中未按预期工作
- 在 IE8 中单选按钮上更改无法正常工作
- 如何让 jQuery methos text() 函数在 IE8 中工作
- 重写一个Javascript函数,该函数可以选择在IE8中工作的活动导航选项卡
- 修复了在页面底部加载时html5标签IE8不工作的问题
- js库无法在IE8中工作
- 输入类型=“file".submit()不工作IE8
- 让cufon在IE7中工作IE8 -我已经按照文档做了所有的事情