0

I tried the solution in Distinguish Chrome from Safari using jQuery.browser but it doesnt work. This solution does but i dont have any way of getting the real version numbers:

$.browser.chrome = $.browser.webkit && !!window.chrome;
$.browser.safari = $.browser.webkit && !window.chrome;

I need to detect the full version numbers so that i can block older versions of these (because their slow/buggy, not for features).

Community
  • 1
  • 1
user1361747
  • 31
  • 2
  • 9

1 Answers1

0

You could use straight Javascript:

if(navigator.userAgent.toLowerCase().indexOf('Chrome'))
{
  var n=navigator.userAgent.split(" ");
  var curVersion="";
  for (var i = 0; i < n.length; i++)
  {
     if(n[i].indexOf("Chrome"))
     {
        curVersionTmp=n[i].split("/");
        curVersion = curVersionTmp[1];   
     }
  }
}
else if(navigator.userAgent.toLowerCase().indexOf('applewebkit'))
{
  var n=navigator.userAgent.split(" ");
  var curVersion="";
  for (var i = 0; i < n.length; i++)
  {
     if(n[i].indexOf("Version"))
     {
        curVersionTmp=n[i].split("/");
        curVersion = curVersionTmp[1];   
     }
  }
}

http://www.useragentstring.com/pages/Safari/

boz
  • 4,891
  • 5
  • 41
  • 68
  • And how is that supposed to reveal the real version number? – user1361747 May 22 '12 at 01:32
  • It's supposed to tell if you're using chrome or safari (that's what your code looks like it's doing) –  May 22 '12 at 01:34
  • although there are code numbers appended to the end of the string in the website –  May 22 '12 at 01:35
  • thats the webkit engine, not the browser version. – user1361747 May 22 '12 at 01:36
  • so for example, Safari 5.1.3 says Version/5.1.3 in the useragent, 5.1 says Version/5.1 –  May 22 '12 at 01:36
  • yeah, and putting a if (is_chrome <100) {alert "chrome"} doesnt do anything, because it reports the webkit engine number of 500+ – user1361747 May 22 '12 at 01:37
  • 543 is webkit build for example Safari/534.53.10 would mean webkit build 543.53.10 –  May 22 '12 at 01:38
  • you should take a look at your link, 534.53.10 is the version that jquery uses to qualify not version 5.1.3 of safari – user1361747 May 22 '12 at 01:39
  • OK, so you dont know how to answer the question, anyone know how to actually detect the real browser version number, because jquery obviously doesnt. – user1361747 May 22 '12 at 01:41