ReidBurke

Avatar

Hi, I'm Reid. This is my website, full of technology, photography, music, and everything else I take interest in. Enjoy. Tell me more...

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!

Explore Related

Previously: Verizon Contract Expires Just In Time for iPhone. More recently: UIUC Admissions Date Moved Up.

Check out content categorized under Hacks, Web Development.

13 Comments, Comment or Ping

  1. Thanks. Worked like a charm for IE.
    Now i just need to sort out my firefox issues :-)

  2. Glad it worked for you!

  3. helped me too - thanks!

  4. Geoff

    Thanks for this as well!

  5. Hey Reid –

    Long time no hear 8-)

    Just a note that you can do this inside the style tag:

    This will take effect in IE6 and IE7
    .yourStylesHere { *font-weight: bold; }

    This will take effect in only IE6
    .yourStylesHere { _font-weight: bold; }

    This statement would make the box 200px in FF, Safari & Opera, 201px in IE6 and 202px in IE7
    .yourStylesHere {
    width: 200px;
    *width: 201px;
    _width: 202px;
    }

    Doing it this way makes your css easier to read 8-)

    Hope you enjoy the new macBook, I can’t wait until Y! issues me one 8-)

    Dav

  6. Hello great! I thought no one would have an answer to this sudden change in the MySpace allowed code list lol.

    Incidentally I really don’t see what the threat to the system it was but cheers!

    With Regards,
    Nicholas Sinclair,
    Slaphead Media LLC.

  7. ejk

    Thanks much!

  8. N. Clark

    Very helpful. Thanks for posting this!

  9. Passi

    Great, thanks a lot! It works fine!

  10. It actually helped ! thx

  11. This change was driving me bonkers. Thanks so much for the help!

  12. Nick

    Doesn’t work any longer. :(

  13. @Nick

    Yes, this broke a few months back when they started scrubbing the comment tag. I’ve given up on styling and use Profile 2.0 on my profile. Good luck!

Reply to “MySpace Hacking: Hiding Code From IE”

About This Post

The post MySpace Hacking: Hiding Code From IE is categorized under Hacks, Web Development.

Join the discussion by leaving your comment or trackback from your own site.

Photography

Endorsed Advertisement

Vote No on Prop 8