测试ie或netscape [英] test for ie or netscape
问题描述
我见过一些可以测试浏览器的代码,并相应地给出值
。我试着阅读常见问题解答,但无法找到这个简单的
版本。我想要的是
如果Netscape-test {
代码为netscape用户
}
如果IE测试{
代码即用户
}
2004年2月3日星期二14:12:12 -0600,Treetop< tr ***** @ netfront.net>写道:
我看到一些代码可以测试浏览器并相应地给出值。我试着阅读常见问题,但无法找到这个简单的版本。
为什么要这样做?如果您要确定哪些代码*可以*
执行,请使用功能检测,而不是浏览器检测。例如,
查看是否支持document.getElementById()使用
if(document.getElementById){
}
迈克
-
Michael Winter
M。****** @ blueyonder.co.inva 盖子(将.invalid替换为.uk以回复)
我创建了一个脚本,用于将数据,文本和图像src发送到
iframe。我有适用于IE的代码,我的代码适用于
Netscape,但我找不到适合两者的代码。如果test-for-netscape {
window.frames [''external''],我想要
跟随
。设置(链接[aNum]);
}
else {
document.external.setup(links [aNum]);
}
Michael Winter < M ****** @ blueyonder.co.invalid>。在消息中写道
news:op ************** @ news-text.blueyonder.co.uk ...On星期二,2004年2月3日14:12:12 -0600,Treetop< tr ***** @ netfront.net>
写道:我看到一些代码可以测试浏览器并相应地给出
值。我试着阅读常见问题解答,但无法找到这个简单版本的
。
为什么要这样做?如果您要确定执行哪些代码
*,请使用功能检测,而不是浏览器检测。对于
示例,要查看是否支持document.getElementById(),请使用
if(document.getElementById){
}
Mike
-
Michael Winter
M.******@blueyonder .co.inva lid(将.invalid替换为.uk到
回复)
< blockquote>文章< bv ************ @ ID-221536.news.uni-berlin.de>,
tr ***** @ netfront.net 启发我们...
我看过一些代码可以测试浏览器并给出值
如果我使用Opera?还是Safari?还是Konqueror? Mac用户倾向于喜欢
Safari。那么Mozilla呢? Linux用户倾向于喜欢Mozilla。
如果我使用Netscape 4怎么样?
关于它可以做什么,它与Netscape 6没什么关系。
如果我使用IE3怎么样?它不支持IE5的一半。
不要测试浏览器。你最终会回到这里想知道为什么
你的代码在Netscape 8出现时什么都不起作用。
测试你想要的对象使用。
if(document.layers)
//为NN4做一些事情
else if(document.all&& ;!document.getElementById)
//用旧IE做点什么
else if(document.getElementById)
//最新浏览器如IE5 + ,NN6 +,Mozilla,歌剧......
-
-
~kaeli~
那些谁跳下巴黎的一座桥......在塞纳河。
http:// www .ipwebdesign.net / wildAtHeart
http://www.ipwebdesign。 net / kaelisSpace
I have seen some codes that can test for the browser and give values
accordingly. I tried to read the FAQ, but was unable to find a simple
version of this. What I want is
If Netscape-test {
code for netscape users
}
If IE-test {
code for ie users
}
On Tue, 3 Feb 2004 14:12:12 -0600, Treetop <tr*****@netfront.net> wrote:
I have seen some codes that can test for the browser and give values
accordingly. I tried to read the FAQ, but was unable to find a simple
version of this.
Why do you want to do this? If you are trying to determine what code *can*
be executed, use feature detection, not browser detection. For example, to
see if document.getElementById() is supported use
if( document.getElementById ) {
}
Mike
--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
I have created a script to send data, text and an image src, to an
iframe. I have code that works for IE, and I have code that works for
Netscape, but I can''t find code that works for both. I want the
following
if test-for-netscape {
window.frames[''external''].setup(links[aNum]);
}
else {
document.external.setup(links[aNum]);
}
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:op**************@news-text.blueyonder.co.uk...On Tue, 3 Feb 2004 14:12:12 -0600, Treetop <tr*****@netfront.net> wrote:I have seen some codes that can test for the browser and give values accordingly. I tried to read the FAQ, but was unable to find a simple version of this.
Why do you want to do this? If you are trying to determine what code
*can* be executed, use feature detection, not browser detection. For example, to see if document.getElementById() is supported use
if( document.getElementById ) {
}
Mike
--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to
reply)
In article <bv************@ID-221536.news.uni-berlin.de>,
tr*****@netfront.net enlightened us with...I have seen some codes that can test for the browser and give values
accordingly. I tried to read the FAQ, but was unable to find a simple
version of this. What I want is
And if I use Opera? Or Safari? Or Konqueror? Mac users tend to like
Safari. What about Mozilla? Linux users tend to like Mozilla.
What about if I use Netscape 4? It isn''t anything close to Netscape 6 in
regards to what it can do.
How about if I use IE3? It doesn''t support half the stuff IE5 does.
Don''t test for browsers. You''ll end up coming back here wondering why
your code doesn''t work in Netscape 8 when it comes out or something.
Test for the objects you want to use.
if (document.layers)
// do something with that for NN4
else if (document.all && ! document.getElementById)
// do something with old IE
else if (document.getElementById)
// recent browsers like IE5+, NN6+, Mozilla, Opera...
--
--
~kaeli~
Those who jump off a bridge in Paris... are in Seine.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
这篇关于测试ie或netscape的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!