I have been trying to detect the user's browser. So I checked my code in Chrome and Edge. It doesn't work in both.
window.addEventListener("load", function() {
let userAgentString = navigator.userAgent;
console.log(userAgentString);
let isChrome = userAgentString.indexOf("Chrome") > -1;
if (isChrome) {
$('#chromeUser').css('display', 'block');
}
});
It makes the div chromeUser
display to block
in both browsers. It means that it doesn't know which browser I'm from.
Ideas anyone?