2010-12-16 51 views
0

我有這個jquery代碼,對於一個普通的瀏覽器允許你有一個粘頭。因此,默認情況下,它會顯示標題的內容,然後在滾動時滾動該標題。問題是它不適用於iPad。有人可以看看代碼,看看有什麼我可以改變,使這項工作在iPad上?使用jquery使固定的控制欄工作ipad使用jquery

// Fixed control bar 
     var controlBar = $('#control-bar'); 
     if (controlBar.length > 0) 
     { 
      var cbPlaceHolder = controlBar.after('<div id="cb-place-holder" style="height:'+controlBar.outerHeight()+'px"></div>').next(); 

      // Effect 
      controlBar.hover(function() 
      { 
       if ($(this).hasClass('fixed')) 
       { 
        $(this).stop(true).fadeTo('fast', 1); 
       } 

      }, function() 
      { 
       if ($(this).hasClass('fixed')) 
       { 
        $(this).stop(true).fadeTo('fast', 1); 
       } 
      }); 

      // Listener 
      $(window).scroll(function() 
      { 
       // Check top position 
       var controlBarPos = controlBar.hasClass('fixed') ? cbPlaceHolder.offset().top : controlBar.offset().top; 

       if ($(window).scrollTop() > controlBarPos) 
       { 
        if (!controlBar.hasClass('fixed')) 
        { 
         cbPlaceHolder.height(controlBar.outerHeight()).show(); 
         controlBar.addClass('fixed').stop(true).fadeTo('slow', 1); 

         // Notifications 
         $('#notifications').animate({'top': controlBar.outerHeight()+notificationsTop}); 
        } 
       } 
       else 
       { 
        if (controlBar.hasClass('fixed')) 
        { 
         cbPlaceHolder.hide(); 
         controlBar.removeClass('fixed').stop(true).fadeTo('fast', 1, function() 
         { 
          // Required for IE 
          $(this).css('filter', ''); 
         }); 

         // Notifications 
         $('#notifications').animate({'top': notificationsTop}); 
        } 
       } 
      }).trigger('scroll'); 
     } 
+0

任何人都可以幫忙嗎?這是否需要付費才能讓某人在iPad Safari瀏覽器上運行? – John 2010-12-18 17:41:22

回答

0

答案是使用了不同的解決方案,如sencha touch。