Skip to content

Instantly share code, notes, and snippets.

@irazasyed
Created April 14, 2013 12:20
Show Gist options
  • Select an option

  • Save irazasyed/5382506 to your computer and use it in GitHub Desktop.

Select an option

Save irazasyed/5382506 to your computer and use it in GitHub Desktop.
JavaScript: Detect Browser
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
var is_opera = navigator.userAgent.toLowerCase().indexOf('opera') > -1;
if(is_chrome) {
alert("This message is for Chrome Users!");
} else if(is_firefox) {
alert("This message is for Firefox Users!");
} else if(is_opera) {
alert("This message is for Opera Users!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment