11.12.2012 Views

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

You must also indicate the comments containing conditional compilation statements by<br />

beginning them with an @ directive and closing them with an @ symbol. For example:<br />

<br />

/*@cc_on @*/<br />

/*@set @debugging = true@*/<br />

<br />

Because the processing of conditional compilation directives happens before normal script<br />

interpretation, you can use it to selectively enable or disable pieces of code. Consider the<br />

following script that defines one of two functions depending upon which version of JScript (if<br />

any) is supported:<br />

<br />

/*@cc_on @*/<br />

/*@if (@_jscript_version >>= 5)<br />

function doTask()<br />

{<br />

}<br />

// some code using advanced IE5+ features<br />

alert('IE Specific code!');<br />

@else @*/<br />

function doTask()<br />

{<br />

}<br />

// some code using standard browser features<br />

alert('Non-IE Specific code!');<br />

/*@end @*/<br />

doTask();

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!