Created
April 20, 2016 09:51
-
-
Save yaroslavKas/6d3a98f441555d17641f59c264de76be to your computer and use it in GitHub Desktop.
Определение браузера
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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