好吧,我是新手,所以请原谅我。我有我的网站,这是为Internet Explorer 9和Safari, Chrome和Mozilla Firefox设置的。但是当我用internetexplorer7在我的电脑上加载我的网站时,它显示了这个条件div
,但它仍然加载它下面的内容。有没有办法阻止它加载内容?
来源:
<!--[if lte IE 8]>
<div style=' clear: both; text-align:center; position: relative;'>
<a href="http://windows.microsoft.com/en-US/internet-explorer/downloads/ie-9/worldwide-languages"><img src="/protected-wp-content/images/internet-explorer-9-update.png" border="0" alt="" /></a>
</div>
<![endif]-->
<!--[if IE 9]>
<script type="text/javascript" src="js/html5.js"></script>
<link rel="stylesheet" href="css/ie.css" type="text/css" media="screen">
<![endif]-->
所以,看起来你想要ie8,而在用户下只能看到更新链接?
先不说这是不是一个好主意,下面是怎么做的:
<!--[if lte IE 8]>
<div style=" clear: both; text-align:center; position: relative;">
<a href="http://windows.microsoft.com/en-US/internet-explorer/downloads/ie-9/worldwide-languages">
<img src="/protected-wp-content/images/internet-explorer-9-update.png" border="0" alt="" />
</a>
</div>
<script type="text/javascript">
document.execCommand("Stop", true, null);
</script>
<![endif]-->
execCommand("Stop")
在IE中停止页面加载。(在其他浏览器中不一致,但这不是一个问题。div;)
如果你想让"——"出现在页面正文中,你可以用
把它括起来<!--[if lte IE 8]><div style="display:none"><[endif]-->
...
<!--[if lte IE 8]></div><[endif]-->
(但不能在IE版本太旧,根本不做CSS的情况下使用
您可以将以下内容包含在
中<!--[if gte IE 9]>
Stuff only Internet Explorer 9 should see..
<![endif]-->
使用JavaScript,您可以隐藏下面加载的div。当然,当Internet Explorer 10版本出来时,这将会中断并需要修改:
<div id='divContainingIE9Content'></div>
<script type='text/javascript'>
if (navigator.userAgent.indexOf("MSIE 9") > 0) {
document.getElementById("divContainingIE9Content").style.display = 'none';
}
</script>