Windows Phone 7, Microsoft’s modern replacement for the ancient Windows Mobile 6, is finally here, and it actually looks quite decent. I haven’t yet used it in person, but judging from various screenshots and videos, it looks like Microsoft really tried to innovate with their new platform, rather than create yet another “3×4 grid of rounded icons” iPhone clone. In particular, the “hubs” concept is a really interesting idea that solves a common problem in a unique way.
But there’s something even more significant about the release of Windows Phone 7 – it is completely incapable of running Windows Mobile 6.x apps. This was absolutely the right decision for Microsoft to make, given Windows Phone 7′s radically different touch-based UI; but it’s a surprising one from Microsoft, which typically opts to preserve backwards compatibility when launching new products.
In fact, has Microsoft ever introduced a major new platform that completely broke compatibility with existing software or file formats? Imagine Microsoft releasing a new version of Windows that couldn’t run any existing Windows apps – it sounds crazy when you think about it from that perspective. Yet that’s basically what they’ve done with Windows Phone 7.
So if only for that reason alone, I hope that Windows Phone 7 succeeds. If the platform does well, Microsoft will have proven to itself that starting over from scratch can pay off. And if that inspires them to make similar revolutionary jumps with their other products, that can only be a good thing.
Reverse Conditional Comments
In one of my previous articles, Target Every Version of IE from a Single Stylesheet, commenter Greg McAusland pointed out a cool technique of using a negative conditional comment to hide code from IE while still sending it to other browsers. I’ve researched the technique a bit further, and for lack of an official term, I’m proposing the term reverse conditional comment.
With a normal conditional comment, the code sent to IE is hidden from other browsers:
Since non-IE browsers don’t recognize the conditional comment syntax, they interpret a conditional comment as a regular HTML comment and ignore all of the inner text content. IE, on the other hand, parses the conditional comment and displays the text content inside of it.
A reverse conditional comment does the opposite – it sends code to browsers that don’t match the condition specified, while hiding it from the ones that do:
By adding the extra inner comment tags, the opening and closing tags of the conditional comment itself are commented out. This makes the inner text content visible again, so non-IE browsers will display:
Meanwhile, IE will parse the conditional comment, but the condition – “if not IE” – will always evaluate to false. Therefore, IE will not display the inner text content.
Note: even though it doesn’t seem necessary, the second
<!is included right before the first closing comment tag (-->) in order to exclude it from the inner text content. If you don’t include this, and you’re testing for a specific version of IE……then when the conditional comment evaluates to false (in IE7, 6, etc.), those browsers will interpret the first closing comment tag as part of the inner text content, and will display this:
For more information on this, see this page on MSDN.
By combining this with a positive conditional comment, you can run one piece of code if the browser is IE (or a certain version of IE), and a different piece of code if the browser is not IE. Essentially, this lets you do browser detection without JavaScript. For example:
Thanks to Greg McAusland for making me aware of this technique!