Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#5977 closed bug (fixed)

.html() will strip <style> tags in IE

Reported by: cmcnulty Owned by:
Priority: major Milestone: 1.4.2
Component: manipulation Version: 1.4.1
Keywords: Cc:
Blocked by: Blocking:


see http://forum.jquery.com/topic/html-stripping-style-in-ie-sometimes for discussion.

when using .html() to insert the following html snippet:

"<style type="text/css">

.test { color: red; }

</style> <div id="nav_controls" class="navControls">

<div id="test_div" class="test">A test</div>

</div> "

innerHTML will strip the <style> tags and content, in IE8. The bug can be a bit tricky to reproduce, as the criteria for stripping the style seems to have something to do with preceding whitespace.

I can't reproduce in FF3.6 or Chrome 3. Untested in IE7 or earlier

Attachments (1)

test.html (789 bytes) - added by cmcnulty 13 years ago.
test case

Download all attachments as: .zip

Change History (4)

Changed 13 years ago by cmcnulty

Attachment: test.html added

test case

comment:1 Changed 13 years ago by john

Component: unfiledmanipulation
Resolution: fixed
Status: newclosed

comment:2 Changed 13 years ago by cmcnulty

For the record, the exact same problem exists for <link> with the exact same symptoms, and the exact same work-arounds (inserting a <br/> before the tag)

comment:3 Changed 13 years ago by cmcnulty

When the <style> or <link> tags are preceded with any of the following text, IE will *not* strip the <style/link> tag (non-exhaustive list):

  • <br/>
  • &nbsp;
  • <span>asdf</span>
  • <div>asdf</div>
  • asdf

IE *will* strip the <style/link> tags if preceded by any of these:

  • carriage returns
  • multiple blank spaces
  • <div></div> (empty div)
  • <span></span> (empty span)
Note: See TracTickets for help on using tickets.