/    Sign up×
Community /Pin to ProfileBookmark

Detect Browser Help Script

Hey all,

I’ve got this really really old IBM file system that was only supported up till IE6 in 2002. Now the users browse to the webpage and the JS detects the IE version…problem is that it doesn’t have IE7 in there.

Can someone please add a line for IE 7 support…it’s not as easy as I thought it would be.

Thanks:

**************CODE****************

<SCRIPT language=”javascript”>
// Check IE version — 5.x, or 4.01 with SP2.
// Also check for javaEnabled
if ((navigator.appVersion.search(/MSIE 6./) == -1 &&
navigator.appVersion.search(/MSIE 5./) == -1 &&
(navigator.appVersion.search(/MSIE 4.01/) == -1 ||
navigator.appMinorVersion.search(/;SP2/) == -1))
{
document.write(“The version must be at least 4.01 with Service Pack 2”);
document.write(“<br>Please <a href=’http://www.microsoft.com/ie/download/’>click here to download the latest version of Internet Explorer</a>”);
}
else if (!navigator.javaEnabled())
{
document.write(“IDMWS requires Java, which is currently disabled in your browser.”);
document.write(“<br>You can enable Java in the Security tab of the Internet Options dialog.”);
document.write(“<br><br>After enabling Java, you may continue using IDMWS.”);
}
else
{
document.write(“Your browser is up-to-date and your settings are OK.”);
document.write(“You may continue using IDMWS”);
}
</SCRIPT>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@scragarOct 07.2008 — Browser detection is a terrible idea, it's unreliable, excludes users of uncommon browsers, and in your case the 7&#37; of the population who don't use windows. Test for features, so if you need java see if java is available and leave it at that:

http://developer.mozilla.org/en/DOM/window.navigator.plugins <-- the standards method of testing for java = search the navigator.plugins array

I'm sure IE has it's own buggy little method for detecting java.
Copy linkTweet thisAlerts:
@Jeff_MottOct 07.2008 — On the off-chance the OP's problem genuinely requires browser detection (which happens), here's a way to do it, copied from jQuery.<i>
</i>var userAgent = navigator.userAgent.toLowerCase();
var browser = {
version: (userAgent.match( /.+(?:rv|it|ra|ie)[/: ]([d.]+)/ ) || [0,'0'])[1],
safari: /webkit/.test( userAgent ),
opera: /opera/.test( userAgent ),
msie: /msie/.test( userAgent ) &amp;&amp; !/opera/.test( userAgent ),
mozilla: /mozilla/.test( userAgent ) &amp;&amp; !/(compatible|webkit)/.test( userAgent )
};
Copy linkTweet thisAlerts:
@inverted_2000authorOct 08.2008 — Hey Jeff,

Thanks for the reply...but since this is a legacy application...I was simply hoping to add an additional line to the script to detect IE7:

Is that possible?

if ((navigator.appVersion.search(/MSIE 6./) == -1 &&

navigator.appVersion.search(/MSIE 5./) == -1 &&

(navigator.appVersion.search(/MSIE 4.01/) == -1 ||

navigator.appMinorVersion.search(/;SP2/) == -1))

Thanks again,

inverted
×

Success!

Help @inverted_2000 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...