Skip to content

Instantly share code, notes, and snippets.

@edadams

edadams/detect-safari.js

Last active Oct 26, 2015
Embed
What would you like to do?
Detect Safari and add a class to the <html> element
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {
document.documentElement.classList.add('is-safari');
}
/**
* Credits:
* http://stackoverflow.com/questions/5899783/detect-safari-using-jquery
* https://developer.mozilla.org/en/docs/Web/API/Element/classList
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.