获得IE版本 [英] getting IE version
问题描述
有没有一种安全的方式来获取IE的版本?我做了谷歌和
发现这段代码:
var version = 0
if(navigator.appVersion。 indexOf(" MSIE")!= -1){
temp = navigator.appVersion.split(" MSIE");
version = parseFloat(temp [1 ]);
}
但我不知道强健如何它是。
Andrew Poulos
Is there a safe way to get the version of IE? I''ve done a google and
found this code:
var version=0
if (navigator.appVersion.indexOf("MSIE") != -1) {
temp = navigator.appVersion.split("MSIE");
version = parseFloat(temp[1]);
}
but I have no idea how "robust" it is.
Andrew Poulos
推荐答案
Andrew Poulos写道:
Andrew Poulos wrote:
有没有一种安全的方式来获得IE的版本?我做了一个google并且
发现了这段代码:
var version = 0
if(navigator.appVersion.indexOf(" MSIE")!= -1) {
temp = navigator.appVersion.split(" MSIE");
version = parseFloat(temp [1]);
}
但我没有想法如何健壮它是。
Andrew Poulos
Is there a safe way to get the version of IE? I''ve done a google and
found this code:
var version=0
if (navigator.appVersion.indexOf("MSIE") != -1) {
temp = navigator.appVersion.split("MSIE");
version = parseFloat(temp[1]);
}
but I have no idea how "robust" it is.
Andrew Poulos
if(/MSIE/.test(navigator.appVersion)&&
!/Opera/.test(navigator.userAgent))}
var IEVersion = navigator.appVersion.match(/ MSIE(\\\ + \\\ +) /)[1];
}
我认为这只适用于IE 4.0+但是(在IE 3.x上没有测试过)
Kevin N.
if (/MSIE/.test(navigator.appVersion) &&
!/Opera/.test(navigator.userAgent) ) }
var IEVersion = navigator.appVersion.match(/MSIE (\d+\.\d+)/)[1];
}
I think this will only work in IE 4.0+ though (haven''t tested it on IE 3.x)
Kevin N.
" Kevin Newman"写了
"Kevin Newman" wrote
Andrew Poulos写道:
Andrew Poulos wrote:
有没有一种安全的方式来获取IE的版本?我做了一个google并且
发现了这段代码:
var version = 0
if(navigator.appVersion.indexOf(" MSIE")!= -1) {
temp = navigator.appVersion.split(" MSIE");
version = parseFloat(temp [1]);
}
但我没有想法如何健壮它是。
Is there a safe way to get the version of IE? I''ve done a google and
found this code:
var version=0
if (navigator.appVersion.indexOf("MSIE") != -1) {
temp = navigator.appVersion.split("MSIE");
version = parseFloat(temp[1]);
}
but I have no idea how "robust" it is.
依赖于导航器属性的任何东西根据定义远非安全
或健壮,作为导航器标识符
的字符串可以很容易地被欺骗,明确的目的是让你认为你正在处理不同的b
浏览器。许多浏览器甚至出货都是欺骗性的。
尝试功能检测。如果一个版本的
JScript中不存在某个功能,但是在另一个版本中,测试其可用性会告诉你
脚本的版本,这反过来又是确定
浏览器版本的线索。
哪些浏览器运行哪些JScript版本,哪些功能附带
哪个版本,是全部列在这里:
< URL:
http://msdn.microsoft.com/library/en...iversioninform
ation.asp>
从Internet Explorer 5.0开始,还有一个本机函数ScriptEngine()
,它给出了正在使用的JScript版本的确切数量。请参阅
< URL:
http://msdn.microsoft.com/library/en...ctScriptEngine 。
asp>
或
< URL: http://4umi.com/web /javascript/jscript.htm >
hth
Ivo
Anything relying on the navigator properties is by definition far from safe
or robust, as the navigator identifier strings can easily be spoofed with
the express purpose of making you think you are dealing with a different
browser. Many browsers even ship spoofed.
Try feature detection. If a feature does not exist in one version of
JScript, but does in another, testing for its availability will tell you
something the version of script, which in turn is a clue towards determining
the version of the browser.
Which browsers runs which JScript versions, and which features come with
which version, is all listed here:
<URL:
http://msdn.microsoft.com/library/en...iversioninform
ation.asp >
As of Internet Explorer 5.0, there is also a native function ScriptEngine()
which gives the exact number of the JScript version in use. See
<URL:
http://msdn.microsoft.com/library/en...ctScriptEngine.
asp >
or
<URL: http://4umi.com/web/javascript/jscript.htm >
hth
Ivo
Andrew Poulos在8/4/2005上午9:31发表以下内容:
Andrew Poulos said the following on 8/4/2005 9:31 AM:
有没有一种安全的方式来获取IE的版本?我做了一个google并且
发现了这段代码:
var version = 0
if(navigator.appVersion.indexOf(" MSIE")!= -1) {
temp = navigator.appVersion.split(" MSIE");
version = parseFloat(temp [1]);
}
但我没有想法如何健壮它是。
Is there a safe way to get the version of IE? I''ve done a google and
found this code:
var version=0
if (navigator.appVersion.indexOf("MSIE") != -1) {
temp = navigator.appVersion.split("MSIE");
version = parseFloat(temp[1]);
}
but I have no idea how "robust" it is.
这就像对浏览器的猜测一样强大。
导航器对象在尝试确定环境时没用,请改为使用
对象检测。
-
Randy
comp.lang.javascript常见问题 - http:/ /jibbering.com/faq &新闻组周刊
It''s about as robust as taking a wild guess at what the browser is. The
navigator object is useless in trying to determine the environment, use
object detection instead.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
这篇关于获得IE版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!