How to check browser version easily

  • Hello,

    I've tested this code with Safari 11.1.1 on macOS.

    Code
    if(device.safariversion GE 11,
      trace('VERIFED');
    ,
      trace('NOT VERIFIED');
    );

    It returns NOT VERIFIED. The check is VERIFED with single "." version as iOS ones but not with macOS ones due to the string comparison.
    There is a way to do it easily without a string parse?

    Better solution at this time :

    Code
    indexoftxt(indexsafariversion, get(device.safariversion), ".");
    subtxt(majorsafariversion, get(device.safariversion), 0, get(indexsafariversion));
    if(majorsafariversion GE 11,
      trace('VERIFED');
    ,
      trace('NOT VERIFIED');
    );

    Edited once, last by benji33 (June 20, 2018 at 12:44 PM).

  • Here another possibility by converting the Safari version-string to a Number (using only the major and minor numbers):

    Code
    txtsplit(device.safariversion, '.', majorver, minorver);
    calc(safariversionnumber, majorver + minorver/10);
    if(safariversionnumber GE 11.0, ...);
    if(safariversionnumber GE 11.1, ...);
    if(safariversionnumber GE 11.2, ...);

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!