Search code examples
javascriptjqueryiosmobile-safariturbolinks

How to target a javascript function only to safari < 6.0 on iOS


I am using a library which has a bug for safari 5.1+ until 5.9 on iOS (mobile) but it work fine after 6.0 (6.0 included) on iOS.

The library in question does allow to remove the element that generates the bug:

Turbolinks.ProgressBar.disable();

How can I say to javascript to apply the function removeProgressBar only to safari <6.0 (strict inferiority) on iOS :

function removeProgressBar {
  Turbolinks.ProgressBar.disable();
}

Important:

  • Safari 6.0 and safari 6.0+must not be affected on iOS nor on desktop (OS X) (I don't want to remove progress bar in this case)

  • safari 5.1.x on desktop (OS X) must not be affected (I don't want to remove progress bar in this case)

  • not sure if it matters but I am using bootstrap 3


Solution

  • Read this post: Browser detection in JavaScript?. It has some useful information on detecting browser and version. Be careful though, because this can never be 100% reliable.