/    Sign up×
Community /Pin to ProfileBookmark

System Performance Advise Ad

Is there a script that will detect which version of Windows you are using? For example, if you’re running Windows XP, then if some javascript detects the OS, then a message will appear? I get the System Performance Advise ads and it always detects the correct OS I’m using.

When I was on a Win2000 Machine, it detect Windows 2000. Now, it’s detecting Windows XP. Here is what I’m talking about….

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@FangJul 31.2003 — If you look at the javascript on their site you will see exactly how then do it!
Copy linkTweet thisAlerts:
@ecrossauthorJul 31.2003 — Okay, there is a external file called useragent.js. I modified it because there was a lot of junk that I didn't want to see. Now, when I open a webpage that is saved onto my computer, I get the following:

par par You are using Windows XP.

What is the par about?

I changed the file extension to a text file so I can show you the code. In my webpage, I'm using these lines:

<html>

<body>

You are using

<script language="Javascript">

<!--This is the detect script

document.writeln(sUserAgent);

-->

</script>

</body>

</html>
Copy linkTweet thisAlerts:
@FangJul 31.2003 — Just strip away all the [COLOR=red]document.writeln[/COLOR] stuff:


[COLOR=green]

<script type="text/javascript">

<!--

var sUserAgent;

var agt=navigator.userAgent.toLowerCase();

var bWindows = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );

var bWindows95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

var bWindowsme = ((agt.indexOf("win 9x 4.90")!=-1));

var bWindows2k = ((agt.indexOf("windows nt 5.0")!=-1));

var bWindowsXP = ((agt.indexOf("windows nt 5.1")!=-1));

var bWindows98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));

var bWindowsnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));

if (bWindowsXP == true)

sUserAgent = 'Windows XP';

else

if (bWindows2k == true)

sUserAgent = 'Windows 2000';

else

if (bWindowsme == true)

sUserAgent = 'Windows Me';

else

if (bWindowsnt == true)

sUserAgent = 'Windows NT';

else

if (bWindows95 == true)

sUserAgent = 'Windows 95';

else

if (bWindows98 == true)

sUserAgent = 'Windows 98';

else

sUserAgent = 'Non-Windows 98';

document.write(sUserAgent);

//-->

</script>

[/COLOR]
[/QUOTE]
×

Success!

Help @ecross 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.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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