Skip to content

Instantly share code, notes, and snippets.

@hasantayyar
Created November 1, 2011 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasantayyar/1330276 to your computer and use it in GitHub Desktop.
Save hasantayyar/1330276 to your computer and use it in GitHub Desktop.
javascript browser detection functions
// seen in pinterest bookmarklet
function isIE() {
return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)
}
function isSafari() {
return /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)
}
function isIOS() {
return navigator.userAgent.match(/iPad/i) != null || navigator.userAgent.match(/iPhone/i) != null || navigator.userAgent.match(/iPod/i) != null || navigator.userAgent.match(/iPod/i) != null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment