/    Sign up×
Community /Pin to ProfileBookmark

using document.all as browser detection

is it valid to use the following to detect that the user’s browser is either IE or Netscape?

if ((document.all || document.layers) {

}

thanks

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliSep 25.2003 — In general terms yes it will work,however,

document.all is too general statement,it will be true for all IE browsers,where as in IE6+ browsers there are differences of how toretrieve some values in JavaScript.

It can be good for Opera as well while you'd optimise your code only for IE<5.5.

document.layers is good for NS browsers <5 versions vers6+ can not be detected by that,for that you will need to get document.getElementById or/ and get the actual browsers version string and compare it
Copy linkTweet thisAlerts:
@pyroSep 25.2003 — If you just want to determine if it is IE or Netscape, why not use navigator.appName?
Copy linkTweet thisAlerts:
@LittleRedauthorSep 25.2003 — I realised that I could use

navigator.appName == "Microsoft Internet Explorer"

to detect IE, but what's the definition for Netscape (does it return 'Mozilla'?)
Copy linkTweet thisAlerts:
@pyroSep 25.2003 — No, it returns "Netscape" via navigator.appName...
Copy linkTweet thisAlerts:
@LittleRedauthorSep 25.2003 — ok ...it seemed to easy to be true!
Copy linkTweet thisAlerts:
@pyroSep 25.2003 — lol ?
×

Success!

Help @LittleRed spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...