Forum Moderators: open
Instead of using browser detection I'm using object detection.
Where can I find object detection examples using javascript for all browsers?
Is there an object detection for Netscape 7.1?
Thanks.
bebop
So for example if you want to use document.elephant, you test for that:
if (document.elephant) {
document.elephant.feed()
}
This SHOULD work for all browsers but it WON'T work for older IE browsers, which will give an error. You need a try-catch to avoid the error - this WILL work as an object test for ALL browsers:
try {
document.elephant.feed()
} catch(e) {
}
Notice how the catch does nothing: the user doesn't see any error.