Conditional Comments for Javascript


/ Published in: JavaScript
Save to your folder(s)

Use this to filter out Ie or other browsers using Javascript


Copy this code and paste it in your HTML
  1. <script type="text/javascript">
  2. /*@cc_on
  3.  
  4.   @if (@_jscript_version == 9)
  5.   document.write("You are using IE9");
  6.  
  7.   @elif (@_jscript_version == 5.8)
  8.   document.write("You are using IE8");
  9.  
  10.   @elif (@_jscript_version == 5.7 && window.XMLHttpRequest)
  11.   document.write("You are using IE7");
  12.  
  13.   @elif (@_jscript_version == 5.6 || (@_jscript_version == 5.7 && !window.XMLHttpRequest))
  14.   document.write("You are using IE6");
  15.  
  16.   @elif (@_jscript_version == 5.5)
  17.   document.write("You are using IE5.5");
  18.  
  19.   @else
  20.   document.write("You are using IE5 or older");
  21.  
  22.   @end
  23.  
  24. @*/
  25. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.