2014-03-27 43 views
0

好的,我有一個http://www.eclectogroove.com/new-site滑塊不起作用。第一個問題是當你點擊箭頭按鈕去下一張幻燈片時,在控制檯中出現這些錯誤。滑塊代理滑稽

Uncaught TypeError: Cannot call method 'getElementsByTagName' of null tabs.js:43 
Uncaught TypeError: Cannot read property 'top' of null jquery.mCustomScrollbar.js:352 
event.returnValue is deprecated. Please use the standard event.preventDefault() instead. 
Uncaught TypeError: Cannot read property 'top' of null jquery.mCustomScrollbar.js:352 
GET http://localhost/eclectogroove/undefined 404 (Not Found) jquery.min.js:127 
GET http://localhost/eclectogroove/undefined 404 (Not Found) jquery.min.js:130 
GET http://localhost/eclectogroove/undefined 404 (Not Found) jquery.min.js:130 

我不知道爲什麼我收到這些錯誤,但另一個問題是滑塊上的圖像會在約20秒後消失隨機。

這裏是tabs.js

init:function(tabid, dselected){ 
var menuitems=document.getElementById(tabid).getElementsByTagName("a") 
this[tabid+"-menuitems"]=menuitems 
for (var x=0; x<menuitems.length; x++){ 
    if (menuitems[x].getAttribute("rel")){ 
     this[tabid+"-menuitems"][x].hasSubContent=true 
     if (menuscript.disabletablinks) 
      menuitems[x].onclick=function(){return false} 
    } 
    else //for items without a submenu, add onMouseout effect 
     menuitems[x].onmouseout=function(){this.className=""} 
    menuitems[x].onclick=function(){menuscript.showsubmenu(tabid, this)} 
    if (dselected=="auto" && typeof setalready=="undefined" && this.isSelected(menuitems[x].href)){ 
     menuscript.showsubmenu(tabid, menuitems[x]) 
     var setalready=true 
    } 
    else if (parseInt(dselected)==x) 
     menuscript.showsubmenu(tabid, menuitems[x]) 
} 

}

代碼如果你需要我張貼任何代碼或與任何其他信息提供給您,請讓我知道。否則一切都可以在http://www.eclectogroove.com/new-site

預先感謝您!

+3

你可以稱之爲「有趣的滑塊」,並在代碼峽谷出售它? – adeneo

+1

沒有id相冊的元素。這就是爲什麼你得到第一條消息 – stackErr

+0

@stackErr你是對的,我發現使用Chrome的調試器相同。考慮寫一個答案。 – kol

回答

1

問題出在您的tabs.js文件中。

您正在調用: menuscript.definemenu("albums", 0)(文件中的最後一行) 但沒有編號爲albums的元素。

這將調用init功能,並在線路43:

var menuitems=document.getElementById(tabid).getElementsByTagName("a") 

其中var menuitems=document.getElementById(tabid)返回null。 因此,錯誤Cannot call method 'getElementsByTagName' of null tabs.js:43

爲了解決這個問題要麼ID albums創建一個元素或只是刪除: menuscript.definemenu("albums", 0)

僅供參考,進入結束了JS的語句用分號(;)的習慣...它非常草率的編程。

+0

那麼如何解決這個問題呢? – thedoggydog

+0

@cdell編輯我的答案。此外,這發生在頁面加載,而不是當你點擊按鈕。 – stackErr

+0

再次感謝你!我更新了,但我仍然有問題。 10-20秒後,滑塊上的圖像仍然消失。我仍然在控制檯中收到此錯誤。 GET http:// localhost/eclectogroove/undefined 404(Not Found)jquery.min.js:127 – thedoggydog