Conditional Compilation

412 views

Published on

Javascript IE hack,

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
412
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Conditional Compilation

  1. 1. Conditional Complication Presented By Prosunjit Biswas Email: prosun.csedu@gmail.com System Developer, Cention AB, Bangladesh.
  2. 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. 3. What is Conditional Compilation? CC is special JS codes for IE that will be ignored by other browser than IE
  4. 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. 5. Tricking Other browsers So, If you write any code inside /*@ ...... @*/ it will be commented to all other browsers than IE
  6. 6. Getting smarter Lets make the code graceful /* @cc_on -------------------> start Tag //code goes here @*/ --------------------> end tag
  7. 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. 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 @*/
  9. 9. Reference: http://www.javascriptkit.com/javatutors/conditionalcompile.shtml
  10. 10. Thank You

×