Use the @ cc_on statement in Jscript to identify the IE browser and version code. For more information, see. Activation condition compilation is supported.
@ Cc_on remarks
@ Cc_on statement activates Conditional compilation in the script engine.
We strongly recommend that you use the @ cc_on statement in comments so that browsers that do not support conditional compilation will accept your script as a valid Syntax:
/* @ Cc_on */
// The remainder of the script. Or, an @ if or @ set statement outside The annotation will also enable Conditional compilation.
Requirements
Version 3
See
Reference
@ If... @ elif... @ else... @ end statement
@ Set statement
The Code is as follows:
/* @ 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
@*/
Concept
Conditional compilation Variables
Other resources
Conditional compilation
@ Cc_on condition compilation of IE
1: alert ("browser version:" + sSuffix)
It is useful to determine the browser version.
Var B =/* @ cc_on! @ */False;/* @ cc_on .....@*/
Can be recognized by ie and executed as a program, and ie Conditional compilation is enabled at the same time. The most common variable is @ _ jscript_version: js version. The last one is the main ie version.
Example:
The Code is as follows:
Var sSuffix = (/* @ cc_on! @ */False )? 'Ie': 'gecko ';
/* @ Cc_on alert ("display browser version:" + @ _ jscript_version )@*/
Alert (@ _ jscript_version)
Alert ("browser version:" + sSuffix)