Conditional compilation in Javascript

Source: Internet
Author: User
Javascript also supports Conditional compilation (whether it is an interpreted or compiled language ). <HTML>
<Body>
<SCRIPT type = "text/JavaScript">
/** // * @ Cc_on
Document. Write ("jscript version:" + @ _ jscript_version + ". <br> ");
/* @ If (@ _ jscript_version> = 5)
Document. Write ("jscript version 5.0 +. <br \/> ");
Document. Write ("You can see the text only when the browser supports jscript5 +. <br> ");
@ Else @*/
Document. Write ("You can see this line of text when using other browsers (such as Firefox, ie 4.x) <br> ");
/** // * @ End
@*/
</SCRIPT>
</Body>
</Html>

After running, My IE will display the three lines in the comment:
JScript version: 5.6.
JScript version 5.0 +.
Only when the browser supports jscript5 + can you see the text.

However, I can't figure out what it will do for me for a long time: Because I write Webpage Programs on the enterprise intranet, the user knows that they all run on Win2k or WINXP, my code never checks whether the browser is IE or nescape. Secondly, when I write a winform program, it is basically not compiled using conditions.

It is only a record. It will be used later.
More introduction on this page: http://sheneyan.com/tech/article/js/conditionalcompile.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.