I followed the instructions mentioned in the topic How to detect Safari, Chrome, IE, Firefox and Opera browser?.
This is my code:
// Chrome 1 - 79
var isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);
// Edge (based on chromium) detection
var isEdgeChromium = isChrome && (navigator.userAgent.indexOf("Edg") != -1);
if (isEdgeChromium == true) {
document.getElementById('EdgeChromiumVisible').style.display = 'block';
} else if (isEdgeChromium == false) {
document.getElementById('ChromeVisible').style.display = 'block';
}
#EdgeChromiumVisible{
display: none;
}
#ChromeVisible{
display: none;
}
<div id="ChromeVisible">Chrome user</div>
<div id="EdgeChromiumVisible">Edge Chromium user</div>
The script works fine in JSFiddle. Unfortunately it does not work at my website.
I am sure that I am missing something, but I cannot figure out what I am doing wrong. Can someone point me in the right direction?
' tags are inserted besides each line in your `script`. That's why you're facing the issue
– ABGR May 24 '20 at 18:38tags) in the HTML-page in WordPress (plain-text view). And there it's viewed without the
tags, as it should be. But somehow when I went to the page-URL in a web browser, the
tags are appearing in the source code in that browser. After I deleted the white lines in the JavaScript code, the
tags disappeared. And even better: The script is now working perfectly! Thanks to you all, for helping me out!
– Sjoerd May 25 '20 at 18:54