Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Condition for MAC or PC?

Status
Not open for further replies.

111101101

Programmer
Oct 16, 2003
39
US
Okay, i need to code in javascript or ASP to determine the client OS of the user.... so can somebody please translate the pseudocode in ASP or javascript:

if (client.os == MAC) then
print "your on a mac";
else if (client.os == PC) then
print "your on a pc";
end if

i need these conditions to determine the course of how to display the content to them.

thanks,
755
 
Try this:

Code:
var userAgent = navigator.userAgent.toLowerCase();
var OSwin = (userAgent.indexOf("win")!=-1);
var OSmac = (userAgent.indexOf("mac")!=-1);

Hope this helps.

Dan
 
P.S.

That will tell you if you're running Windows or Mac OS, but you may need to extend it to check for things like Linux running on a PC, etc.

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top