在HTML/JavaScript的,我怎么能识别用户正在使用的浏览器,并通过选择的代码,我的意思是:如果浏览器crhome这么做...其他... 谢谢
Q
如何识别浏览器?
-1
A
回答
5
你可以使用navigator
并获得所有的细节。只需进行谷歌搜索!
<div id="example"></div>
<script type="text/javascript">
txt = "<p>Browser CodeName: " + navigator.appCodeName + "</p>";
txt+= "<p>Browser Name: " + navigator.appName + "</p>";
txt+= "<p>Browser Version: " + navigator.appVersion + "</p>";
txt+= "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>";
txt+= "<p>Platform: " + navigator.platform + "</p>";
txt+= "<p>User-agent header: " + navigator.userAgent + "</p>";
document.getElementById("example").innerHTML=txt;
</script>
希望这有助于! :)
+1
其信息是不正确的,它显示mozzila&netscape o_o –
+0
嘿,它显示了一切。浏览器的细节。你必须在使用之前操作它。 –
4
由于浏览器是移动目标,因此不建议检测浏览器。例如,今天的Chrome不支持功能X,但几个月后它开始支持它。如果你简单地把
// Here I detect Chrome browser without a third-party library
if (navigator.userAgent.toLowerCase().indexOf('chrome') === -1) {
doFeatureX()
else {
console.log('Sorry, no Feature X for you.')
}
那么你锁定Chrome用户进行永远。如果你想
if (Modernizr.geolocation) {
// do stuff with user's coordinates
}
但当然你可以检测浏览器:你应该做的,而不是feature detection有不少libraries来帮你。例如,你想鼓励人们升级他们的浏览器:
// Here I'm using jQuery
if ($.browser.msie && parseInt($.browser.version, 10) < 9) {
// show link to http://microsoft.com/ie
} else if ($.browser.mozilla && parseInt($.browser.version, 10) < 11) {
// show link to http://mozilla.com/firefox
} // etc.
相关问题
- 1. 浏览器识别
- 2. 识别浏览器
- 3. HttpWebRequest:如何识别浏览器?
- 4. 如何识别浏览器选项卡?
- 5. 浏览器如何识别视频?
- 6. 如何识别黑莓的浏览器
- 7. 的JavaScript浏览器识别
- 8. 浏览器如何识别ASP.NET/C#中的用户断开浏览/浏览器浏览器#
- 9. 浏览器扩展:识别浏览器活动
- 10. Safari浏览器语音识别
- 11. 在Ionic2中识别平台浏览器
- 12. 使用javascript进行浏览器识别
- 13. 浏览器中的QRcode光学识别
- 14. 会话无法从浏览器识别
- 15. Firefox浏览器不能识别table.cells吗?
- 16. 浏览器指纹识别和火狐
- 17. Silverlight语音识别(在浏览器中)
- 18. Web浏览器中的语音识别
- 19. 识别跨浏览器的元素
- 20. 浏览器不识别PHP代码
- 21. 节在浏览器中无法识别
- 22. 如何识别WordPress中访问者的浏览器语言?
- 23. 浏览器如何识别登录表单?
- 24. 如何识别使用JavaScript或jQuery的浏览器选项卡?
- 25. Selenium - 它如何识别浏览器的安装位置?
- 26. 如何识别Flash Builder中的浏览器
- 27. 如何让浏览器识别用户的解析?
- 28. 网站如何识别网页浏览器?
- 29. 如何识别网站是否源自移动浏览器?
- 30. 如何识别浏览器是否支持angularjs?
取决于你想做什么,你可以使用功能检测,而不是 – Esailija
拜托你知道如何寻找的东西在谷歌不您? http://www.google.nl/search?hl=zh-CN&q=How+to+identify+the+browser – albertjan
检查Javascript中的导航器对象 –