有些时候我们需要针对某些IE下的兼容性写单独的JS处理代码。有多种做法:
1.通过检测navigation.userAgent来判断是否是IE,再编写IE分支的处理代码:
2.通过声明@cc_on 语句可以在脚本的注释内启用条件编译功能,这样对于非IE浏览器就会将识别为注释而忽略(实测,这种方式在IE6-9将适用!):
/*@cc_on @if (@_jscript)
alert("hello world");
@end @*/
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn