Forum Moderators: open

Message Too Old, No Replies

Check browser

         

cwbp

4:32 am on Jan 22, 2004 (gmt 0)



Hi,

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

Purple Martin

11:43 pm on Jan 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The simple answer is to just detect whatever object you want to use.

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.