检查用户正在使用哪种浏览器 [英] Check what kind of browser the user is using
问题描述
我有一个包含几个jQuery动画,命令等的网站。
它在Google Chrome和Firefox中运行得非常完美,但对于IE来说却是一件非常痛苦的事情。
是否有我可以在我的网页开始处插入的代码(在加载其他任何内容之前)以检查用户正在使用的浏览器,并且如果它是IE,则会弹出一个警告框他(好心的)考虑切换到FIrefox或Chrome?
信息:我对.NET,PHP或其他服务器没有任何知识(目前并不需要它)。
为什么不直接使用IE IF命令(其他浏览器将它们视为注释)?:
<! - [if IE]>< div id = ie-warning>请切换浏览器!< / div><![endif] - >
不需要JS
对于以下版本:
<! - [if IE lte 7]>您的IE版本为7或更低版本<![endif] - - >
( IE小于或等于7)
<! - [if IE gte 8]>您的IE版本是8或更高版本<![endif] - >
(IE大于或等于8)
很抱歉,如果我遗漏了一些东西,但我认为这会起作用。
更多信息: http ://msdn.microsoft.com/en-us/library/ms537512(v = vs.85).aspx
I have a website with a few jQuery animations, commands, etc. It runs flawlessly in Google Chrome and Firefox, but is a real pain when it comes to IE.
Is there a code I can insert at the beginning of my webpage (before loading anything else) in order to check what browser the user is using, and if it's IE, get a warning box to pop up to ask him (kindly) to consider switching to FIrefox or Chrome?
INFO: I have no knowledge whatsoever in .NET, PHP, or other server-side languages (didn't really need it so far).
Why don't you just use the IE-only IF commands (other browser treat them as comments)?:
<!--[if IE]><div id="ie-warning">Please switch browsers!</div><![endif]-->
No JS needed
For versions:
<!--[if IE lte 7]>Your IE is version 7 or lower<![endif]-->
(IE Less Than or Equal to 7)
<!--[if IE gte 8]>Your IE is version 8 or higher<![endif]-->
(IE Greater Than or Equal to 8)
Sorry if I'm missing something, but I think that will work.
Further info: http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx
这篇关于检查用户正在使用哪种浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!