As the following works on all browsers except Internet Explorer 7, which I need it to work on mainly,
$( window ).scroll(function() { alert("Hello"); })
Is there any way that this could be implemented myself? Not too sure on how to go about it. Would anyone be able to point me in the right direction?
Make sure to use jQuery 1.x since that version will keep x-browser support. If you use jQuery 2.x you will loose x-browser support.
$(window).scroll(function(){});
DEMO jQuery 1.11.0 => IE6,7,8 support YES
DEMO jQuery 2.x(edge) => IE6,7,8 support NO
In return, jQuery 2.x is smaller, faster, and can be used in JavaScript environments where the code needed for old-IE compatibility often causes problems of its own.
I usually prefer to use a timer instead of scroll events. I haven't tried on IE7 though.
I would do something like so:
var topy = 0;
var interval = setInterval(function(){
if ($(window).scrollTop() !== topy) {
topy = $(window).scrollTop();
// whatever you need to do...
}
},200);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.