加载jQuery的条件注释替代方案

use*_*419 0 javascript jquery internet-explorer

因为jQuery 2+不支持IE 8,所以我需要使用以前的版本:jQuery 1.9.

当使用IE> 8时,有没有办法在使用IE <= 8和jQuery 2+时包含jQuery 1.9.我尝试使用条件注释:

<!--[if lt IE 9]><!--><script> .. googleapis jquery 1.9 .. </script><!--<![endif]-->
<!--[if gte IE 9]><!--><script> .. googleapis jquery 2+ .. </script><!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)

问题是它无法正常工作,我发现它的某些信息不再受支持了:http://msdn.microsoft.com/en-us/library/ie/hh801214( v = vs.85).aspx

还有另外一种方法吗?

T.J*_*der 6

您希望IE8版本在注释掉的块中,但非IE9版本不是:

<!--[if lt IE 9]> <script> .. googleapis jquery 1.9 .. </script> <![endif]-->
<![if !IE|gte IE 9]> <script> .. googleapis jquery 2+ .. </script> <![endif]>
Run Code Online (Sandbox Code Playgroud)

带警报的实时示例

IE8识别条件注释,但其他浏览器不识别(包括较新的IE).

你也可能想要!IE在第二个中,只是为了完整性,如上所述.