开发者

jQuery function is fired twice in IE...?

开发者 https://www.devze.com 2023-01-21 01:14 出处:网络
I have a function that fires when the scroll bar hits the bottom. For some reason now, IE is firing the event twice. It wasn\'t doing it before. I don\'t have a duplicate function, and not have the JS

I have a function that fires when the scroll bar hits the bottom. For some reason now, IE is firing the event twice. It wasn't doing it before. I don't have a duplicate function, and not have the JS declared twice. It's fi开发者_Python百科ne in Opera, FF, Chrome. I don't know why it's doing so in IE. Oh how I hate M$ and this troublesome browser.

jQuery(document).ready(function(){          
        jQuery(window).scroll(function(){
            if  (jQuery(window).scrollTop() == jQuery(document).height() - jQuery(window).height()){
               scrollPost();
            }
        }); 

    });

Edit: Actually it's double posting in Safari too. Another browser I don't like.


I found the solution here.

Jquery scroll hits twice on IE

Apparently IE and Safari are known for this issue. I had to use the debounce method to keep it from firing twice. I used Ben Alman's dotimeout plugin and it worked pefectly fixing the IE and Safari issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号