开发者

How do I check if the browser is running on a MAC? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_如何学JAVA Closed 10 years ago.

As the title describes.

I need to see if the machine accessing my page is a MAC or something else


You could check the userAgent like this:

return navigator.userAgent.indexOf(\"Mac OS X\") != -1

But, this isn't a reliable method as it can be spoofed...but since there is no javascript absolute for this, not a terrible option. Feature detection is a better alternative if you want to see what the browser will/won't support...depends if you're after metrics of actually enabling/disabling features.


You can use:

<html>
<body>

<script type="text/javascript">
document.write("Browser CodeName: " + navigator.appCodeName);
document.write("<br /><br />");
document.write("Browser Name: " + navigator.appName);
document.write("<br /><br />");
document.write("Browser Version: " + navigator.appVersion);
document.write("<br /><br />");
document.write("Cookies Enabled: " + navigator.cookieEnabled);
document.write("<br /><br />");
document.write("Platform: " + navigator.platform);
document.write("<br /><br />");
document.write("User-agent header: " + navigator.userAgent);
</script>

</body>
</html>

ref: http://www.w3schools.com/js/js_browser.asp


You are better off doing feature detection http://www.modernizr.com/


There is a very lightweight version for jQuery available Here:

http://www.stoimen.com/blog/2009/07/16/jquery-browser-and-os-detection-plugin/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜