异步加载Deezer Javascript SDK

时间:2013-12-28 18:51:25

标签: javascript deezer

我正在尝试按照此处的说明异步加载Deezer JS SDK: http://developers.deezer.com/sdk/javascript/init

使用空白页并准确复制提供的样本,我收到错误:

Cannot read property 'length' of null dz.js:67
TypeError: Cannot read property 'length' of null
    at Object.DZ.Event.resolve (http://cdn-files.deezer.com/js/min/dz.js:59:138)
    at Array.<anonymous> (http://cdn-files.deezer.com/js/min/dz.js:150:10)
    at Object.DZ.Event.triggerEvent (http://cdn-files.deezer.com/js/min/dz.js:62:342)
    at Object.DZ.player.onLoad (http://cdn-files.deezer.com/js/min/dz.js:143:10)
    at DZ.onDeezerLoaded (http://cdn-files.deezer.com/js/min/dz.js:7:52)
    at DZ.communication.receive (http://cdn-files.deezer.com/js/min/dz.js:109:1) 

以下是我使用的代码:

<div id="dz-root"></div>
<script>
    window.dzAsyncInit = function() {
        DZ.init({
        appId  : 'xxxxx',
        channelUrl : 'http://www.blbablalba.com/channel.php'
        });
    };
    (function() {
        var e = document.createElement('script');
        e.src = 'http://cdn-files.deezer.com/js/min/dz.js';
        e.async = true;
        document.getElementById('dz-root').appendChild(e);
    }());
</script>

我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

我知道这是一个老问题,但我今天遇到了同样的问题,并意识到修改document.body.innerHTML的价值导致了这个问题。

=&GT;删除该行代码解决了它! : - )