Detect Safari using jQuery

前端 未结 13 1652
面向向阳花
面向向阳花 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-27 10:23

    This will determine whether the browser is Safari or not.

    if(navigator.userAgent.indexOf('Safari') !=-1 && navigator.userAgent.indexOf('Chrome') == -1)
    {
        alert(its safari);
    }else {
        alert('its not safari');
    }
    

提交回复
热议问题