Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is any significant browser missing document.documentElement for an HTML doc?

document.documentElement is a DOM1 property and so was specified more than 13 years ago. In my experiments, it's reliable in IE6 onward and in vaguely recent versions (I haven't gone back far) of Firefox, Chrome, Safari, Mobile Safari, Opera, and Konqueror when I use the HTML5 doctype. So that covers a fair range of layout engines: Trident, Gecko, WebKit, Presto, and KHTML.

(It even works if I omit the actual html tag in my markup [which I'm allowed to do in HTML5 — and apparently even IE6 adds it in for me despite it never having heard of HTML5 — but almost certainly never will in practice].)

Is there any significant browser — Blackberry? Android? — in which I cannot assume document.documentElement will be present and will refer to the root html element in an HTML document?

like image 476
T.J. Crowder Avatar asked Apr 15 '26 03:04

T.J. Crowder


1 Answers

Depends on your requirements. Older versions of Blackberry's Browser, before version 6 of the OS, may not have had support for it. But the browser was so bad that any JavaScript enabled site hardly worked anyway.

According to Wikipedia, all major rending engines support it. It seems like that table is using the IE version rather than the actual version of Trident. Trident (IE), Gecko (Firefox), Webkit (Safari, Chrome), and Presto (Opera) all support it. The Tasman rendering engine is largely obsolete and unused. I wouldn't worry about it.

In my personal experience, I've had no problems from myself or customers using that property on a reasonably modern browser.

All mobile browsers, Safari/iOS, Android, even Internet Explorer on Windows Phone 7 support it. Recent BlackBerries do as well.

like image 77
vcsjones Avatar answered Apr 19 '26 06:04

vcsjones



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!