Check browser if IE or Edge code should work otherwise there is no way to do this?

0 like 0 dislike
8 views
Check browser if IE or Edge code should work otherwise not. But that is not written apparently.
get_name_browser function(){ var ua = navigator.userAgent; if (ua.search(/YaBrowser/) > 0) return 'Yandex Browser'; 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 'undefined'; } var browser = get_name_browser(); if (browser == 'Edge'||'Internet Explorer') { alert('Code was triggered.'); } else { alert('Code is NOT triggered.'); }
by | 8 views

1 Answer

0 like 0 dislike
if (browser == 'Edge' || browser == 'Internet Explorer') {

or

if (['Edge' , 'Internet Explorer'].includes(browser)) {
by
110,608 questions
257,186 answers
0 comments
32,714 users