Version mistake with IE 8 when checks it with JS
-
18-04-2021 - |
Question
Found problem with values of verions of IE8. Please, see the pics.
1) When I check navigator.appVersion it shows version 7.
2) But when I open Info->About IE, it shows that version is 8:
How it can be? It can make problems when I check user's browser version.
La solution
One reason this happens can be you beeing in a different layout mode (check F12/Developer Tools).
Regardless of the navigator telling you something wrong. You should NEVER do Feature detection through Browser identification! Always test if the function is there or not! Like addEventListener. Instead of checking document.all
(which for a long time was microsoft only) to determin if you'd use addEvent
or addEventListener
, check if addEventlistener
is in the document;
if (document.addEventListener){
document.addEventListener(....
}
else{
document.addEvent(...
}
There is a library called Modernizr which does all the ever needed feature detections for you (and is modular) and even adds CSS classes to style things when expl. IE6 doesn't support opacity
hope I helped!