Home > Web Front-end > JS Tutorial > Two ways to write JS code for IE_javascript skills

Two ways to write JS code for IE_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:42:40
Original
1091 people have browsed it

Sometimes we need to write separate JS processing code for compatibility under certain IE. There are many ways to do it:

1. Determine whether it is IE by detecting navigation.userAgent, and then write the processing code for the IE branch:
2. By declaring the @cc_on statement, you can enable conditions in the comments of the script. Compilation function, so that non-IE browsers will recognize them as comments and ignore them (actually tested, this method will be applicable in IE6-9!):

Copy code The code is as follows:

/*@cc_on @if (@_jscript)
alert("hello world");
@end @*/
Related labels:
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template