I am trying to use javascript to apply a certain style to pages based on the browser that the user uses. I can detect all browsers except IE / Edge. In my code snippet, I'm just trying to detect IE / Edge and apply the style.
Here is my code:
var bodyStyle = document.querySelector("#bodyArea");
if((navigator.userAgent.indexOf("Edge") != -1 ) || (!!document.documentMode == true ))
{
alert("asdf");
bodyStyle.style.paddingTop = "500px";
}
else
{
bodyStyle.style.paddingTop = "300px";
}
When I put a warning in the else section, it gives me a warning, but it does not work with the if part. Therefore, I think that my problem occurs when I try to detect IE / Edge. Let me know if it lies elsewhere. If anyone has any feedback, we will be very grateful. Thanks in advance!
user5187524
source
share