javascript - scrolltop() doesn't work in IE9 at all -
function onscroll(){ document.getelementbyid("fly").style.top=""+ $(document).scrolltop() * 5 +"px"; }
check out... sigh
not working 1 bit in ie9... haven't tested in ie10 yet. yes, works in chrome, firefox, , every browser under sun except damned ie.
listen window
's scroll
event instead:
$(window).on('scroll', function() { document.getelementbyid("fly").style.top = $(document).scrolltop() * 5 +"px"; });
tested in latest chrome, firefox, opera 15 , ie8. seems work fine in browser, main issue ie not parse body
's onscroll
attribute window.onscroll
property other browsers do. live test case. test case source:
<body onscroll="42;">
document.body.innerhtml = 'does ' + (window.onscroll ? '' : '<b>not</b> ') + 'parse body onscroll attribute window.onscroll';
so assigning event handler directly window.onscroll
solve issue, you're using jquery .on()
method preferred event binding. patches cross-browser inconsistencies , don't have worry overwriting pre-existing handlers.
Comments
Post a Comment