There are countless questions about this but the answers to all of them are out of date with IE no longer supporting conditional statements, jQuery no longer supporting detection without a migrate plugin etc. This question has been asked before but there are no answers that remain supported in 2020.
The tag is a perfect example of how simple this should be. Surely there must be a way to detect the browser (IE) and then set a DIV with a warning message to visible.
There have been answers in the past but even they aren't supported now. Of course any JS used to detect the browser would need to be compatible with IE.
My first thought was to do something that would detect MSIE
and then display a DIV. It seems up for debate as to if you should use feature or browser detection based on everything I've looked through for the last few hours.
The reason I need this message in IE is because the site isn't compatible due to new JS and CSS features. I wouldn't know where to start with this so apologies for not posting any code. All it needs is something like this.
// Detect if Internet Explorer
// If no do nothing
// If Internet Explorer
// Set iewarning to visible
.iewarning {
display: none;
}
<div class="iewarning">Update your browser</div>
I don't know how to go about detecting features, the browser or user agent but this question has to be asked again now that there's no conditional statements or jQuery support. Pure JS is the most ideal solution. Any approaches using that would be appreciated. Thanks in advance.
EDIT
If feature detection could be used to make a DIV visible.
if (typeof Promise == "undefined") {
document.getElementByClass("iewarning").style.display = "block";
}
.iewarning {
display: none;
}
<div class="iewarning">Please upgrade your browser</div>
That doesn't work though but seems like it could be a more minimal solution.
EDIT
Using a query selector instead should work? I'm entirely lost but willing to use feature detection if someone can help me get it working.
if (typeof Promise == "undefined") {
document.querySelector("div.iewarning").style.display = "block";
}
.iewarning {
display: none;
}
<div class="iewarning">Please upgrade your browser</div>