2013-08-06 47 views
0

我正在使用流動遊戲來解決播放視頻,但它不工作的網站上工作。接管了一個項目,流水遊戲加載平視顯示器,但不是視頻

控制檯告訴我專門有一個與我的頭線與video.addEventListener開頭的問題:

說:不能調用方法的addEventListener。

如果你看不懂,我對編碼很陌生。 site:sems-usa.com/Duramatic/index.html 如果需要,我可以發佈更多的上下文。任何幫助深表感謝。

<!-- 
function MM_preloadImages() { //v3.0 

    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); 

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) 

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} 

} 
//--> 
var video = document.getElementById('video'); 
video.addEventListener('click',function(){ 
Uncaught TypeError: Cannot call method 'addEventListener' of null 
video.play(); 
},false); 
</script> 

更多上下文

// a- tags with class "myPlayer" are transformed into video players 

flowplayer("a.myPlayer", "video/flowplayer-3.2.6.swf", { 



// this is the player configuration. You'll learn on upcoming demos. 

plugins: { 

    controls: { 

     volume: false 

    } 

} 

});

回答

0

Uncaught TypeError: Cannot call method 'addEventListener' of null說,你var video = document.getElementById('video');沒有真正找到你的頁面上的元素與視頻的ID(視頻被指定爲null

嘗試改變線

<a class="myPlayer" href="video/Duramatic0713.flv"> 

<a id="video" class="myPlayer" href="video/Duramatic0713.flv"> 
+0

在我的html中?看起來不像是。我應該找到包含此標籤的元素並更改它的ID嗎? – user2658433

+0

是的,看看我上面的編輯,讓我知道如果它有幫助或不:) – Shaun

+0

試圖改變它,看起來不像它的工作。當我從瀏覽器查看我的代碼時,它顯示id =「video_api」的標記(在我的代碼中看不到)。之前是「fp_8315223_api」。所以它有某種影響。 – user2658433

相關問題