Detect Safari using jQuery

前端 未结 13 1573
面向向阳花
面向向阳花 2020-11-27 10:09

Though both are Webkit based browsers, Safari urlencodes quotation marks in the URL while Chrome does not.

Therefore I need to distinguish between these two in JS.

相关标签:
13条回答
  • 2020-11-27 10:44
    //Check if Safari
      function isSafari() {
          return /^((?!chrome).)*safari/i.test(navigator.userAgent);
      }
    //Check if MAC
         if(navigator.userAgent.indexOf('Mac')>1){
            alert(isSafari());
         }
    

    http://jsfiddle.net/s1o943gb/10/

    0 讨论(0)
提交回复
热议问题