<script type="text/javascript"> /*@cc_on @if (@_jscript) // This code is inside a conditional comment, which is also a // regular JavaScript comment. IE runs it but other browsers ignore it. alert('You are using Internet Explorer); @else*/ // This code is no longer inside a JavaScript comment, but is still // inside the IE conditional comment. This means that all browsers // except IE will run this code. alert('You are not using Internet Explorer'); /*@end @*/ </script>
按理說這是IE中javascript條件注釋。
以/*@cc_on 開頭,@*/結束的。而且JScript是Microsoft自己的JavaScript解釋器的名字,而@_jscript變量在IE中為True。
但我在IE7中,似乎認不到條件注釋。
firefox卻可以。不知道是IE版本不對,還是怎么回事。