Greg's Blog

helping me remember what I figure out

Conditional Compilation

| Comments

What with the buzz going on around xmlHttpRequest, I decided to have a little play with the technology (yes I know very me too of me). One tutorial/example site I stumbled across ”Guide to Using XMLHttpRequest (with Baby Steps)” used some interesting JavaScript: Conditional Compilation. Here is an example: [js] /*@cc_on @*/ /*@if (@_jscript_version >= 4) alert(“JScript version 4 or better”); @else @*/ alert(“You need a more recent script engine.”); /*@end @*/ [/js] From the looks of it, it’s an IE only thing, but I wonder what the advantages are of using this code over a regular browser check? Is this a more reliable way than using window.ActiveXObject and, if you are specifically playing around with xmlHttpRequest, based on that condition making the correct create object call?