Kre*_*dns 3 html javascript internet-explorer-6
我需要能够判断是否在IE 6中查看了某个页面.如何在javascript中执行此操作而忽略7,8或其他浏览器的版本?
直接从马的嘴里(和一个谷歌搜索):
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}
Run Code Online (Sandbox Code Playgroud)