2017-04-05 10 views
1

我有一個頁面在Chrome上運行良好,但在IE或Firefox上不起作用。我把這個Jsfiddle放在一起,它顯示了問題的一部分:https://fiddle.jshell.net/dkwsswdw/2/Jquery無法正常工作Firefox和IE在鏈接上執行的動作點擊

如果你在Chrome上打開它,你應該能夠點擊窗口頂部的向下箭頭並從div向下滾動到div。如果您在Firefox或IE中打開它,它將停止工作。

任何想法?我知道在FF和IE中沒有正確調用jQuery有問題,但我不確定它是如何適用於此問題的。 (我在這看着廣泛而我只是太新,jQuery來弄清楚到底如何適用。)

注:

如果它是有幫助的,這裏的實際循環,我在WordPress的運行,以顯示其職務和「當前」類添加到第一篇文章中的循環:

<?php 

     // The Arguments 
     $args = array(
      'post_type' => 'strange', 
      'posts_per_page' =>-1, 
      'order_by' => 'menu_order' 

     ); 

     $c = 0; 
     $class = ''; 

     // The Query 
     $the_query = new WP_Query($args); ?> 

     <?php 

     // If we have the posts... 
     if ($the_query->have_posts()) : ?> 

     <!-- Start the loop the loop --> 
      <?php while ($the_query->have_posts()) : $the_query->the_post(); 
      $c++; 
      if ($c == 1) $class .= ' current'; // if the item is the first item, add class current 
      else $class = ''; 
      ?> 

       <div id="strange-container" class="strange-container <?php echo $class; ?>">  

        <img src="<?php the_field('strange-img'); ?>" alt="<?php the_title(); ?>" /> 

        <span><?php the_field('strange-text'); ?></span> 

       </div> 

      <?php endwhile; endif; ?> 

     <?php wp_reset_postdata(); ?> 
+0

試過這個,以及基於我在#2另一個線程看到:https://fiddle.jshell.net/dkwsswdw/19/ – ludditedev

回答

2

僅供參考,您的圖片是一個htpasswd後面。

也就是說,一些瀏覽器喜歡在body上進行動畫製作,而其他人則喜歡在html上進行動畫製作。改變你的線,看起來像這樣:

$('body').animate({ 

這樣:

$('html,body').animate({ 
+1

謝謝!這確實解決了它!有沒有像caniuse.com這樣的資源,我可以參考jQuery這樣的瀏覽器首選項?編寫我自己的腳本對我來說是新的,我很樂意在網上找到我自己的解決方案。 – ludditedev

+0

不是我所知道的......這是你剛剛獲得經驗的那些東西之一。 – GentlemanMax

+0

Gotcha。再次感謝。今天我一直在擺弄這一段時間,事實證明這是一個簡單的修復。 – ludditedev

相關問題