开发者

How can I check if the user running chrome 11 version? (javascript code)?

My site only 开发者_Python百科works on chrome 11 how can I check if the user runs this version?


You can do browser detection like already answered by others, but feature detection might be a better road to take.

You can get some inspiration by reading this post: Browser detection versus feature detection

Also read about browser detection pitfalls here: https://developer.mozilla.org/en/Browser_Detection_and_Cross_Browser_Support

Also you can read more about feature detection here: http://michaux.ca/articles/feature-detection-state-of-the-art-browser-scripting

And finally you can use the modernizr library here: http://www.modernizr.com/


using jquery.

if ($.browser.chrome && $.browser.version == 11)


var running_chrome_11 = navigator.userAgent.toLowerCase().indexOf('chrome/11') > -1;

This will either be true or false.

However as suggested, it is highy recommend to check against the current features, rather than the version number. An example might be:

if(window.localStorage){ // you can run local storage }


parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2]) >= 11
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜