
This post contains JavaScript.
I have found on the Internet the following function for detecting Internet Explorer version:
function vIE(){return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;}
- The property navigator.appName returns something like:
- The property navigator.userAgent returns something like:
- The function returns the conditional result of the expression <logical> ? <value_for_true> : <value_for_false>
- Constructor RegExp creates a new object and defines a regular expression as: [0-9] defines a character set formed by any character in the range 0-9; {x,} defines the minimum x number of occurrences used in the match; () creates a subexpression.
- RegExp.exec(string) returns an array of the matches of the regular expression in the given string or null if no match is found. The returned array contains both matches for the regular expression as well as for present subexpressions. For this reason, the second element in the array is parsed to a float value and returned by the function.
Note: You may get a wrong version for Internet Explorer 8 if you use Compatibility View, as at the time of this writing Blogspot domain is in the Compatibility View List (more information at this page). Check the list by typing in the Internet Explorer 8 address bar: .










0 comentarii:
Trimiteţi un comentariu