Detect Safari using jQuery

前端 未结 13 1660
面向向阳花
面向向阳花 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:21

    For checking Safari I used this:

    $.browser.safari = ($.browser.webkit && !(/chrome/.test(navigator.userAgent.toLowerCase())));
    if ($.browser.safari) {
        alert('this is safari');
    }
    

    It works correctly.

提交回复
热议问题