2013-10-16 174 views
-1

我正在使用下面的JavaScript來拉動'回到頂部'按鈕時向下滾動。jquery javascript chrome/Safari瀏覽器問題

這對Firefox非常有用 - 但不適用於Chrome/Safari。

jQuery(document).ready(function(){ 
    jQuery("#totop").hide(); 
    jQuery(window).scroll(function(){ 
     if (jQuery(this).scrollTop() > 100) { 
      jQuery('#totop').fadeIn(); 
     } else { 
      jQuery('#totop').fadeOut(); 
     } 
    }); 

    jQuery('#totop').click(function(){ 
     jQuery("html, body").animate({ scrollTop: 0 }, 660, 'easeInOutExpo'); 
     return false; 
    }); 
}); 

演示站http://demov3.joostrap.com

我一直在使用noConflict嘗試。

+0

我沒有看到它在Chrome或FF。 – j08691

+0

你有沒有得到任何javascript錯誤? – geevee

+0

檢查你的控制檯是否有異常...:'Uncaught TypeError:Object function(a,b){return document.id(a,b,this.document)}沒有方法'noConflict''。 Chrome 32.0.1664.3金絲雀 –

回答

1

正如我在評論中提到的,Google Chrome和其他一些WebKit瀏覽器在固定位置和z-index方面存在已知問題。

檢查網頁源代碼中,我建議以下變化:

<-- Set the body element z-index value to 0 (inline or 
    on the CSS stylesheet) --> 
<body class="com_content view-featured layout- task- frontpage itemid-101 no-rtl" style="z-index: 0;"> 

    <div class="body-wrapper"> 
     ... 
    </div> 

    <-- Stick the link as the last element within the body element, and change 
     its z-index value to 9999 (on the CSS stylesheet) --> 
    <a href="#" id="totop"></a> 
</body> 
+0

MelanciaUK - 謝謝...但仍然沒有快樂!按照您的建議編輯。 – user991830

+0

god dammit ...發現問題 - 刪除z-index:-999; on'.joostrapslider-container'和'#slider'修復了這個問題 – user991830