Safari 3.0.x doesn't support the document.compatMode property to detect whether the document is rendered in standards or in quirks mode. Safari 3.1 and newer do support it. How do I detect the document mode in Safari 3.0.x if document.compatMode is not available?
+1
A:
A quick Google search results in: "HOWTO determine the document's compatibility mode"
Basically you create a div
with an invalid css style that would only work in quirks mode. You then check the new div
's style to see if the css was accepted. If it was accepted, the document is in quirks mode.
To paraphrase the code:
var el = document.createElement('div');
el.style.cssText = 'position:absolute;width:0;height:0;width:1';
var compatMode = el.style.width === '1px' ? 'BackCompat' : 'CSS1Compat';
I would test this for you but I can't run Safari. Please test it if you can and report the results in a comment.
brianpeiris
2009-10-16 06:34:15
It works perfectly in Safari 3.0.x
Fabian Jakobs
2009-10-16 12:01:14
No good. That code results "BackCompat" in IE when IE is in standards mode.
Garrett
2010-06-26 20:53:50
The Google article uses Browser detection and expandos -- obviously no good.
Garrett
2010-06-27 18:50:58
A:
Garrett
2010-06-27 07:03:28