Skip to content

Instantly share code, notes, and snippets.

@yaroslavKas
Created April 20, 2016 09:51
Show Gist options
  • Save yaroslavKas/6d3a98f441555d17641f59c264de76be to your computer and use it in GitHub Desktop.
Save yaroslavKas/6d3a98f441555d17641f59c264de76be to your computer and use it in GitHub Desktop.
Определение браузера
function get_name_browser(){
// получаем данные userAgent
var ua = navigator.userAgent;
// с помощью регулярок проверяем наличие текста,
// соответствующие тому или иному браузеру
if (ua.search(/Chrome/) > 0) return 'Google Chrome';
if (ua.search(/Firefox/) > 0) return 'Firefox';
if (ua.search(/Opera/) > 0) return 'Opera';
if (ua.search(/Safari/) > 0) return 'Safari';
if (ua.search(/MSIE/) > 0) return 'Internet Explorer';
// условий может быть и больше.
// сейчас сделаны проверки только
// для популярных браузеров
return 'Не определен';
}
var browser = get_name_browser();
if(browser == 'Firefox'){
jQuery('.submit').attr('disabled', true);
...........
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment