Detect Safari using jQuery

前端 未结 13 1634
面向向阳花
面向向阳花 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/

提交回复
热议问题