Answer the question
In order to leave comments, you need to log in
Browser check if IE or Edge code should work otherwise not, how to do it?
Browser check if IE or Edge code should work otherwise not. But something is written wrong apparently.
function get_name_browser(){
var ua = navigator.userAgent;
if (ua.search(/YaBrowser/) > 0) return 'Яндекс Браузер';
if (ua.search(/rv:11.0/) > 0) return 'Internet Explorer 11';
if (ua.search(/MSIE/) > 0) return 'Internet Explorer';
if (ua.search(/Edge/) > 0) return 'Edge';
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';
return 'Не определен';
}
var browser = get_name_browser();
if (browser == 'Edge'||'Internet Explorer') {
alert('Код сработал.');
} else {
alert('Код НЕ сработал.');
}
Answer the question
In order to leave comments, you need to log in
if (browser == 'Edge' || browser == 'Internet Explorer') {
if (['Edge' , 'Internet Explorer'].includes(browser)) {
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question