Activate conditional compilation support.
@cc_on Notes The
@cc_on statement activates conditional compilation in the script engine.
It is strongly recommended to use @cc_on statements in comments to make browsers that do not support conditional compilation accept your script as valid syntax:
/*@cc_on*/
// The remainder of the script. Alternatively, an @if or @set statement outside the comment will also activate conditional compilation.
Requires
Version 3
See
Reference
@if...@elif...@else...@end statement
@set statement
/*@cc_on
@if (@_jscript_version > 5.7)
document.write("You are using IE8 ");
@elif (@_jscript_version == 5.7 && window.XMLHttpRequest)
document.write("You are using IE7");
@elif (@_jscript_version == 5.6 || (@_jscript_version == 5.7 && !window.XMLHttpRequest))
document.write("You are using IE6");
@elif (@_jscript_version == 5.5)
document.write("You are using IE5.5");
@else
document.write("You are using IE5 or older");
@end
@*/
Concepts
Conditional compilation variables
Other resources
Conditional compilation
@cc_on conditional compilation of IE
1: alert("The browser version is:" sSuffix)
It is very useful to determine the browser version
var b = /*@cc_on!@*/false; where /*@cc_on ..... @*/
The parts in between can be recognized by IE and executed as a program, while enabling IE's conditional compilation. The most commonly used variable is @_jscript_version: js version, the last digit is the ie main version number
Example:
var sSuffix = ( /*@cc_on!@*/false ) ? 'ie' : 'gecko' ;
/*@cc_on alert("Show browsing Browser version number: " @_jscript_version) @*/
alert(@_jscript_version)
alert("Browser version is " sSuffix)
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