I have to use $('html, body').animate()
to make the snippet fully cross-browser patible, but this is inconvenient when chaining animations as they will sometimes act on both <html>
and <body>
.
IE8 depends on having 'html' while Chrome or Safari depend on having 'body', so therefore i must include both.
Why the discrepancy?
I have to use $('html, body').animate()
to make the snippet fully cross-browser patible, but this is inconvenient when chaining animations as they will sometimes act on both <html>
and <body>
.
IE8 depends on having 'html' while Chrome or Safari depend on having 'body', so therefore i must include both.
Why the discrepancy?
Share Improve this question edited Mar 8, 2011 at 22:55 trusktr asked Mar 8, 2011 at 10:53 trusktrtrusktr 45.5k58 gold badges210 silver badges287 bronze badges 5- Which version(s) of IE does this pertain to? – BoltClock Commented Mar 8, 2011 at 10:54
- @BoltClock - I'd imagine all as I doubt MS would change the fundamental way the browser is built – Alex Commented Mar 8, 2011 at 10:58
-
@Alex: They did do something with the DOM near the root level though. In IE6,
html
wasn't the root element; in IE7,html
and one other element were at the root level. – BoltClock Commented Mar 8, 2011 at 11:02 - to pensate for many things that do not work in IE,but work in all other browsers. – DhruvPathak Commented Mar 8, 2011 at 11:02
- see updated question. basically html is for IE and body is for Chrome/Safari. – trusktr Commented Mar 8, 2011 at 22:56
2 Answers
Reset to default 5I think it's because the scroll bars (that I presume you're animating) are built into the browser at different locations. I've had this problem before and had to use the same method you incorporate. Bit annoying, but then so are most things when you want them to work across all browsers :-)
You should never even do $('html').animate
since you should only animate content and the html tag is not a content tag. Stick with $('body').animate
and it should work in all browsers.