@reid

MySpace Hacking: Hiding Code From IE

Note This no longer works. I use their Profile 2.0 now anyway.

Today I noticed that my MySpace profile looked awful in Internet Explorer. I recently changed some stuff in my profile but didn’t touch my custom CSS. However, after looking through the code, I discovered the problem: MySpace is now scrubbing out “<!” from my profile.

This is bad, because I make use of Internet Explorer’s conditional comments to hide some CSS from the browser. Basically, I was using this:

<![if !IE]>
<style>
.yourStylesHere { font-weight: bold; }
</style>
<![endif]>

Now, the “<!” bit is replaced with “..“, making the conditional statement worthless and exposing IE to what it shouldn’t be seeing.

After some research, I found that the IE-only tag <comment> works just as well as the conditional comment I used before. By simply replacing the conditional tags with the <comment> tag, everything worked great in Internet Explorer (even IE 7).

Now I have:

<comment>
<style>
.yourStylesHere { font-weight: bold; }
</style>
</comment>

This works great. I hope this helps someone!