如果浏览器支持
语句是如果可以HTML语句,因为我想,当有人使用Internet Explorer <p>You are using Internet Explorer we don't support this browser</p>
如果浏览器支持
而对于Firefox的</p>Your browser is supported</p>
这是可能的这个文本弹出?
这里是我的代码:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>My title</title>
<p class="accent">
<!--[if IE]>
According to the conditional comment this is IE<br />
<![endif]-->
<!--[if IE 6]>
According to the conditional comment this is IE 6<br />
<![endif]-->
<!--[if IE 7]>
According to the conditional comment this is IE 7<br />
<![endif]-->
<!--[if IE 8]>
According to the conditional comment this is IE 8<br />
<![endif]-->
<!--[if IE 9]>
According to the conditional comment this is IE 9<br />
<![endif]-->
<!--[if gte IE 8]>
According to the conditional comment this is IE 8 or higher<br />
<![endif]-->
<!--[if lt IE 9]>
According to the conditional comment this is IE lower than 9<br />
<![endif]-->
<!--[if lte IE 7]>
According to the conditional comment this is IE lower or equal to 7<br />
<![endif]-->
<!--[if gt IE 6]>
According to the conditional comment this is IE greater than 6<br />
<![endif]-->
<!--[if !IE]> -->
According to the conditional comment this is <comment>not</comment> IE<br />
<!-- <![endif]-->
</p>
</head>
<body>
MY code here
</body>
</html>
没有HTML if语句,但Internet Explorer有一些名为conditional comments的东西。所以你可以说
<!--[if IE]>
<p>You are using Internet Explorer we don't support this browser</p>
<![endif]-->
<!--[if !IE]> -->
</p>Your browser is supported</p>
<!-- <![endif]-->
虽然,第二部分涵盖了其他一切,不仅仅是Firefox浏览器。
所以呢!意思是不是IE –
@ user2748588是的,它的确如此。看到链接,你可以在这里看到如何使用它来检测各种IE版本。 –
我不明白我只是使用IE浏览器,并从http://www.quirksmode.org/css/condcom.html代码,它说这个浏览器不是,即 –
在jQuery.browser看看:http://api.jquery.com/jQuery.browser/
的$ .browser属性提供关于网络浏览器 信息 正在访问的页面,如浏览器本身所报告的 。它包含四个最流行的 浏览器类(Internet Explorer, Mozilla,Webkit和Opera)以及 版本信息中的每一个的标记 。
可用的标志是:
的WebKit(在jQuery 1.4的)野生动物园 (不建议使用)歌剧MSIE Mozilla时,这一 属性将立即可用。它 因此可以安全地使用它来确定是否要调用 $(document).ready()来确定 。 $ jbrowser 属性在jQuery 1.3, 中已弃用,其功能可能会移至 ,该版本是jQuery未来 发行版中的团队支持的插件。
因为$ .browser使用 的navigator.userAgent确定 平台,更是容易受到 浏览器本身来欺骗用户或失实陈述 。总是最好的 ,以尽可能避免浏览器专用代码 。 $ .support 属性可用于检测 对特定功能的支持,而不是依赖$ .browser的 。
感谢您的帮助。 –
你可以用CSS和HTML来做到这一点,用CSS检测浏览器和DISPLAY或隐藏HTML标签。 – jcho360