在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. 的JavaScript浏览器识别
- 6. 浏览器如何识别ASP.NET/C#中的用户断开浏览/浏览器浏览器#
- 7. 使用javascript进行浏览器识别
- 8. 浏览器中的QRcode光学识别
- 9. 浏览器指纹识别和火狐
- 10. Firefox浏览器不能识别table.cells吗?
- 11. Web浏览器中的语音识别
- 12. 节在浏览器中无法识别
- 13. 在Ionic2中识别平台浏览器
- 14. Drupal识别用户/浏览器
- 15. 如何识别已打开浏览器的对象?
- 16. 如何根据浏览器特征识别访问者?
- 17. 如何识别IE浏览器生成和生成号码?
- 18. 如何识别网站是否源自移动浏览器?
- 19. 如何让浏览器识别密码更改?
- 20. 如何从浏览器识别设备和检索唯一ID
- 21. 浏览器如何识别登录表单?
- 22. 如何检查语音识别是否支持浏览器
- 23. Selenium - 它如何识别浏览器的安装位置?
- 24. 如何识别Flash Builder中的浏览器
- 25. 如何识别使用JavaScript或jQuery的浏览器选项卡?
- 26. 如何识别浏览器栏(Internet Explorer)是否隐藏?
- 27. iPhone:如何让Safari浏览器识别电子名片?
- 28. 如何识别在浏览器中播放视频的窗口
- 29. 如何通过浏览器识别javascript是否是暗号
- 30. 如何使iOS中的“识别浏览器为”
取决于你想做什么,你可以使用功能检测,而不是 – Esailija
拜托你知道如何寻找的东西在谷歌不您? http://www.google.nl/search?hl=zh-CN&q=How+to+identify+the+browser – albertjan
检查Javascript中的导航器对象 –