![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #2 |
|
Senior Coder ![]() ![]() Join Date: Jun 2002
Location: near Oswestry
Posts: 4,509
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
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 |
|
|
|
|
|
PM User | #3 |
|
The thread killer ![]() ![]() Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
![]() |
try testing for document.implementation
__________________
liorean <[lio@wg]> Articles: RegEx evolt wsabstract , Named Arguments Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards Last edited by liorean; 03-11-2003 at 08:14 PM.. |
|
|
|
|
|
PM User | #4 | |
|
Senior Coder ![]() ![]() Join Date: Jun 2002
Location: near Oswestry
Posts: 4,509
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Quote:
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark |
|
|
|
|
|
|
PM User | #5 |
|
The thread killer ![]() ![]() Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
![]() |
__________________
liorean <[lio@wg]> Articles: RegEx evolt wsabstract , Named Arguments Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards |
|
|
|
|
|
PM User | #6 |
|
Senior Coder ![]() ![]() Join Date: Jun 2002
Location: near Oswestry
Posts: 4,509
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
cool
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark |
|
|
|
|
|
PM User | #7 |
|
Super Moderator ![]() ![]() Join Date: May 2002
Location: metro DC
Posts: 3,168
Thanks: 1
Thanked 18 Times in 18 Posts
![]() |
var dom1 = document.implementation && document.implementation.hasFeature('XML', '1.0') && document.implementation.hasFeature('HTML', '1.0');
That should be pretty accurate, if vendors do what they are supposed to. |
|
|
|
|
|
PM User | #8 |
|
Super Moderator ![]() ![]() Join Date: May 2002
Location: metro DC
Posts: 3,168
Thanks: 1
Thanked 18 Times in 18 Posts
![]() |
Might be a good idea to remove the DOM1 XML check, as IE is stupid... and apparently so is Opera. hmph
var dom1 = document.implementation && document.implementation.hasFeature('HTML', '1.0'); |
|
|
|
|
|
PM User | #9 |
|
The thread killer ![]() ![]() Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
![]() |
Hey - using strict warnings?
try this var dom1=('implementation' in document)&& document.implementation.hasFeature('HTML', '1.0'); or, a bit longer but more backwards compatible: var dom1=(typeof document.implementation!='undefined')&& document.implementation.hasFeature('HTML', '1.0');
__________________
liorean <[lio@wg]> Articles: RegEx evolt wsabstract , Named Arguments Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards |
|
|
|
|
|
PM User | #10 | |
|
Senior Coder ![]() ![]() Join Date: Jun 2002
Location: near Oswestry
Posts: 4,509
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Quote:
__________________
"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 10:49 PM.. |
|
|
|
|
|
|
PM User | #11 |
|
The thread killer ![]() ![]() Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
![]() |
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.
DevEdge JavaScript 1.5 Core Reference says it was introduced in JavaScript 1.4. MSDN Library Scripting JScript says it was introduced in JScript 1.0 (ie3).
__________________
liorean <[lio@wg]> Articles: RegEx evolt wsabstract , Named Arguments Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards |
|
|
|
|
|
PM User | #12 |
|
Senior Coder ![]() ![]() Join Date: Jun 2002
Location: near Oswestry
Posts: 4,509
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
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 |
|
|
|
|
|
PM User | #13 |
|
The thread killer ![]() ![]() Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
![]() |
Well, please notify me of any results you find - I'm interested in how much I can use this.
__________________
liorean <[lio@wg]> Articles: RegEx evolt wsabstract , Named Arguments Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards |
|
|
|
|
|
PM User | #14 |
|
Senior Coder ![]() ![]() Join Date: Jun 2002
Location: near Oswestry
Posts: 4,509
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
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 var DIM = ("images" in document); * moz (ditto): true * netscape 3-4: error * opera 5-7: false * opera 4: true! * ie6: true * ie4-5: error * safari: true You can see the test page at http://www.brothercake.com/Ref/in.html
__________________
"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 12:08 AM.. |
|
|
|
|
|
PM User | #15 |
|
Senior Coder ![]() ![]() Join Date: Jun 2002
Location: near Oswestry
Posts: 4,509
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
A couple of things that have come up on further testing:
- ("implementation" in document) returns true for the mac version of Opera 6; but presumably you can't actually use it. - given the strange O7 results, I did another set of tests using (typeof document.implementation). The results are interesting: * moz (ns6.01 and moz1.3b): [object DOMImplementation] * netscape 3-4: undefined * opera 7: [object HTMLDOMImplementation] * opera 4-6: undefined .. except: * opera 6/mac: [object DOMImplementation] (but presumably you can't actually use it) * opera 3: null * ie6: [object] * ie5/mac: [object Implementation] (?) * ie5/win: undefined * ie4: undefined * safari: [object DOMImplementation] What this suggest to me is that, as an object test for DOM1 support, document.implementation has some caveats - 1 - it's undefined in win/ie5 - which may or may not be appropriate 2 - it returns an object collection in the mac version of Opera 6, but presumably you can't actually use it. 3 - it returns null (rather than "undefined") in Opera 3 Updated test results
__________________
"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 11:03 AM.. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|