2014-04-02 44 views
0

我正在開發一個基於Opencart的項目,主題是Tranda Social(我認爲它已被棄用)。我面臨的問題是,在主頁上,我只能看到滾動效果(例如,向下滾動時將導航欄保持在固定位置,或者通過單擊帶有向上箭頭的按鈕進入頂部)。經過一些研究後,我得出結論,出於某種原因,Javascript函數沒有被正確調用。Opencart主題中的Javascript滾動問題

setTimeout(function() { 

    /* Menu */ 
    $('#menu ul > li > a + div').each(function (index, element) { 

     var menu = $('#menu').offset(); 
     var dropdown = $(this).parent().offset(); 
     i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#menu').outerWidth()); 
     if (i > 0) { 
      $(this).css('margin-left', '-' + (i + 5) + 'px'); 
     } 
    }); 

    /* Fixed Menu */ 
    $(function() { 

     var msie6 = $.browser == 'msie' && $.browser.version < 7; 
     if (!msie6) { 
      var top = $('#bottomh').offset().top; 
      $(window).scroll(function (event) { 
       var y = $(this).scrollTop(); 
       if (y >= top) { 
        $('#bottomh').addClass('bottomfixed'); 
       } else { 
        $('#bottomh').removeClass('bottomfixed'); 
       } 
      }); 
     } 
    }); 

    $(function() { 

     var msie6 = $.browser == 'msie' && $.browser.version < 7; 
     if (!msie6) { 
      var top = $('#bottomh').offset().top; 
      $(window).scroll(function (event) { 
       var y = $(this).scrollTop(); 
       if (y >= top) { 
        $('#bottomh').addClass('bottomfixed'); 
       } else { 
        $('#bottomh').removeClass('bottomfixed'); 
       } 
      }); 
     } 
    }); 

    /* Margin Menu */ 
    $(function() { 

     var msie6 = $.browser == 'msie' && $.browser.version < 7; 
     if (!msie6) { 
      var top = $('#bottomh').offset().top; 
      $(window).scroll(function (event) { 
       var y = $(this).scrollTop(); 
       if (y >= top) { 
        $('#container').addClass(' topmargin'); 
       } else { 
        $('#container').removeClass(' topmargin'); 
       } 
      }); 
     } 
    }); 

    $(function() { 
     var msie6 = $.browser == 'msie' && $.browser.version < 7; 
     if (!msie6) { 
      var top = $('#bottomh').offset().top; 
      $(window).scroll(function (event) { 
       var y = $(this).scrollTop(); 
       if (y >= top) { 
        $('#container').addClass(' topmargin'); 
       } else { 
        $('#container').removeClass(' topmargin'); 
       } 
      }); 
     } 
    }); 
}, 500); 

當我在主頁中導航時,固定菜單和邊距菜單註釋後的功能不起作用。另外如果你注意到,每個功能都有重複(不知道是什麼原因)。你有什麼想法嗎?任何幫助將不勝感激。

+0

這些功能應該只在Internet Explorer 6中做** **你確定你正在使用這種垃圾瀏覽器訪問網站嗎? – shadyyx

+1

@shadyyx'if(!msie6)'完全與你所想的相反:) –

+0

@ChetanPaliwal真的,我錯過了那個'!'的標誌......我的壞:-( – shadyyx

回答

0

這是由Slidesshow模塊(Nivo Slider)引起的一個問題,因爲它與JS錯誤有關。卸載 - 重新安裝模塊可以解決問題。