2010-12-16 55 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。