Body.scrollTop Is Deprecated In Strict Mode. Please Use 'documentElement.scrollTop' If In Strict Mode And 'body.scrollTop' Only If In Quirks Mode.
I'm receiving the error: body.scrollTop is deprecated in strict mode. Please use 'documentElement.scrollTop' if in strict mode and 'body.scrollTop' only if in quirks mode. My code
Solution 1:
Dagg Nabbit gave the solution. Change
$('html,body').animate({scrollTop: divTag.offset().top},'slow');
to
$('html').animate({scrollTop: divTag.offset().top},'slow');
if you want to avoid the deprecation warning in Chrome. (Why is body.scrollTop
deprecated?)
It works because documentElement
is the html
node:
$('html')[0] === document.documentElement //-> true
$('body')[0] === document.body //-> true
But your code is working now (albeit with a warning) and it will keep working when Chrome removes the "quirky" behavior. You shouldn't change your code if you want to continue supporting browsers that use body.scrollTop
to represent the scrolling viewport in standards mode (older Chrome and Safari, I think).
Post a Comment for "Body.scrollTop Is Deprecated In Strict Mode. Please Use 'documentElement.scrollTop' If In Strict Mode And 'body.scrollTop' Only If In Quirks Mode."