generally, document.getElementById and document.createElement are useful object tests for this.
However, Opera 6 returns a function for createElement, even though it can't add the created element to the page. So to cater for that, I'd do something like this:
var agt = navigator.userAgent.toLowerCase();
var op6 = (agt.indexOf("opera/6")!=-1||agt.indexOf("opera 6")!=-1)?true:false;
var DOM = (typeof document.getElementById!="undefined" && typeof document.createElement!="undefined" && !op6)?true:false;
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
Originally posted by liorean try testing for document.implementation
Much better But isn't that DOM2 ?
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
Originally posted by liorean var dom1=('implementation' in document)
Hey that's interesting. I didn't realise you could use in like that
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
Last edited by brothercake; 03-11-2003 at 09:49 PM..
Yeah, I know. I've only seen it used internally in Mozilla/Netscape code before I started using it. I have no idea how the support for it is, except that op7, moz and jscript5.6 (comes with ie6, and a few other microsoft products) support it.
Excellent; thanks. I shall have to run some tests ..
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
I did a couple of different tests - one using implementation, and one using the images collection, like a control.
The results are mostly what you'd expect, but a couple of surprises in there:
var DOM = ("implementation" in document);
* moz (tested ns6.01 and moz1.3b): true
* netscape 3-4: error
* opera 7: false ... the first time you view the page in each Opera session, but true on refresh or if you visit it again in the same session
* opera 4-6: false
* ie6: true
* ie4-5: error
* safari: true
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
Last edited by brothercake; 03-11-2003 at 11:08 PM..
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
Last edited by brothercake; 03-12-2003 at 10:03 AM..