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.
jQuery's browser detection docs mark "safari" as deprecated.
Is there a better method or do I just stick with the deprecated value for now?
If you are checking the browser use
$.browser
. But if you are checking feature support (recommended) then use$.support
.You should NOT use $.browser to enable/disable features on the page. Reason being its not dependable and generally just not recommended.
If you need feature support then I recommend modernizr.
For checking Safari I used this:
It works correctly.
Using a mix of
feature detection
andUseragent
string:Usage:
if (is_safari) alert('Safari');
Or for Safari only, use this :
http://jsfiddle.net/s1o943gb/10/
This will determine whether the browser is Safari or not.