小编joe*_*g P的帖子

youtube iframe活动

我尝试捕捉youtube iframe的事件:http: //lab.joergpfeiffer.de/videofull/youtube.php

所以我先打电话给api

<script type='text/javascript' src='http://www.youtube.com/player_api'></script>
Run Code Online (Sandbox Code Playgroud)

我设置了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>
Run Code Online (Sandbox Code Playgroud)

并尝试稍后设置事件

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'); }
Run Code Online (Sandbox Code Playgroud)

无论我做什么,都没有发生任何事件.我读了10次iframe api.它应该实际工作.

任何的想法?

javascript youtube iframe events

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

events ×1

iframe ×1

javascript ×1

youtube ×1