【发布时间】:2011-10-15 00:30:06
【问题描述】:
我尝试捕捉 youtube iframe 的事件: http://lab.joergpfeiffer.de/videofull/youtube.php
所以我先调用 api
<script type='text/javascript' src='http://www.youtube.com/player_api'></script>
我设置了 iframe
<iframe id="ytfullplayer" type="text/html" width="640" height="390" src="http://www.youtube.com/p/B93C3D017CB2D65A?enablejsapi=1&origin=lab.domain.de" frameborder="0" ></iframe>
并尝试在稍后设置事件
var ytfullplayer;
function onYouTubePlayerAPIReady() {
console.log('onYouTubePlayerAPIReady');
ytfullplayer = new YT.Player('ytfullplayer', {
events: {
'onReady': testfunc,
'onPlaybackQualityChange': testfunc,
'onStateChange': testfunc,
'onError': testfunc
}
});
}
function testfunc(){ alert('hello'); }
无论我做什么,都不会触发任何事件。我读了 iframe api 10 次。它应该确实有效。
有什么想法吗?
【问题讨论】:
标签: javascript events iframe youtube