User Agent testing sucks, but sometimes you need it for subtle things. In my case I was using it to adjust what I was showing for keyboard shortcut keys (Command or Control). Nothing super major.
if (navigator.userAgent.indexOf('Mac OS X') != -1) {
$("body").addClass("mac");
} else {
$("body").addClass("pc");
}
The statements in there use jQuery to add a body class, but that’s not required, you could do whatever.
- Tech Tricks answered 9 months ago
- You must login to post comments
Your Answer
Please login first to submit.