How to check if Mac or PC using Javascript

Sometimes, in your webpage, you might wanted to redirect the visitor accordingly for MAC or PC. For Identifiying MAC or PC, here is a simple code using Javascript.

if (navigator.userAgent.indexOf('Mac OS X') != -1) {
  $("body").addClass("mac");
} else {
  $("body").addClass("pc");
}

No comments:

Post a Comment