MXOXW

Life always finds a way.

JavaScript 权威指南-Web浏览器中的JavaScript

| Comments

13.4.6 IE里的条件注释
HTML注释

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!--[if IE 6]>
This content is actually inside an HTML comment.
It will only be displayed in IE 6.
<![endif]-->

<!--[if lte IE 7]>
This content will only be displayed by IE 5, 6 and 7 and earlier.
lte stands for "less than or equal". You can also use "lt", "gt" and "gte".
<![endif]-->

<!--[if !IE]> <-->
This is normal HTML content, but IE will not display it
because of the comment above and the comment below.
<!--> <![endif]-->
This is normal content, displayed by all browsers.


<!--[if IE]><script src="excanvas.js"></script><![endif]-->

JavaScript注释
JScript是Microsoft的JavaScript解释器的名字, 而@_jscript变量在IE总是为true.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*@cc_on
@if (@_jscript)
// This code is inside a JS comment but is executed in IE.
alert("In IE");
@end
@*/



/*@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
@*/

13.6 安全性

同源策略
跨站脚本
拒绝服务攻击

评论