简体   繁体   English

跨浏览器兼容性

[英]cross-browser compatibility

On the new safari browser 6.0 on Lion 10.8 this code is not executing properly. 在Lion 10.8上的新的野生动物园浏览器6.0中,此代码无法正确执行。 Works fine in firefox and iPad safari. 在Firefox和iPad野生动物园中可以正常工作。 But on the mac it keeps vibrating as I scroll up and down. 但是在Mac上,随着我上下滚动,它一直在振动。 I'm trying to keep the top banner scrolling until the button reach the top of the page at which point i want the buttons to stay fixed. 我试图保持顶部的横幅滚动,直到按钮达到在这一点,我想按钮留固定在页面的顶部。

here's the link to the page: 这是页面的链接:

http://www.persiantunedpiano.com/Mirror/events.htm http://www.persiantunedpiano.com/Mirror/events.htm

here's the js: 这是js:

<script type="text/javascript">
<![CDATA[

  $(document).scroll(function() {var scrollTop = $(window).scrollTop();
                        scroll(0, scrollTop);
                        if (scrollTop > 189) {
                            //alert(scrollTop);
                            $('#top_links').css('position', 'fixed');
                            $('#top_links').css('top', '0');
                            $('#left_links').css('position', 'fixed');
                            $('#left_links').css('top', '57px');


                        } else {
                            //alert('2');

                            $('#top_links').css('position','absolute');
                            $('#top_links').css('top', '186px');
                            $('#left_links').css('position', 'absolute');
                            $('#left_links').css('top', '242px');
                            //allertSize();
                        }
                        });


//]]>
</script>

Hmmm... seems like it is too slow, this will speed it up can't be sure it will be fast enough: 嗯...似乎太慢了,这会加快速度,但不能确保速度足够快:

(I'm adding the jQuery elements to the closure so you don't have to search for them 4 times per move.) (我将jQuery元素添加到了闭包中,因此您不必每次移动搜索4次。)

<script type="text/javascript">

  var top_links = $('#top_links');
  var left_links = $('#left_links');

  $(document).scroll(function() {
     var scrollTop = $(window).scrollTop();
     scroll(0, scrollTop);
     if (scrollTop > 189) {
       top_links.css('position', 'fixed')
                .css('top', '0');
       left_links.css('position', 'fixed')
                 .css('top', '57px');
     }
     else {
       top_links.css('position','absolute')
                .css('top', '186px');
       left_links.css('position', 'absolute')
                 .css('top', '242px');
     }
 });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM