2. Conditional Compilation – Cool Javascript for IE Some time we need to write JS code for IE Coz IE needs special attention So, We have something Special in IE for JS This is : Conditional Compilation
3. What is Conditional Compilation? CC is special JS codes for IE that will be ignored by other browser than IE
4. Introducing CC ( CC tricks ) difference between this two JS codes /* alert('this is commented '); */ /*@ alert(' this is not commented in IE but commented in other browser '); @*/
5. Tricking Other browsers So, If you write any code inside /*@ ...... @*/ it will be commented to all other browsers than IE
6. Getting smarter Lets make the code graceful /* @cc_on -------------------> start Tag //code goes here @*/ --------------------> end tag
7. Hello World Example /* @cc_on alert('Will be shown only in IE'); @*/ /* @cc_on @if ( @_win32 ) alert(' 32 bit Windows'); @else alert('Not 32 bit windows system'); @*/
8. Boiling water to make COFFEE Implementing browser Specific job / * @cc_on /*@ if (@_jscript_version >= 5 ) alert('IE with Support 5+'); @elif (@_jscript_version >= 4 ) alert('IE with Support 4+'); @else @*/ alert('Non IE Browser'); /*@end @*/