views:

68

answers:

1

I'm observing that when using an HTML5 doctype (<!DOCTYPE html>), assigning a string containing HTML entities to a DOM object's innerHTML does not convert/render those entities on IE8 (and probably other IE versions).

document.getElementById('some-div').innerHTML = 'Doesn&apos;t work.';

Does anybody have a solution? I've come across this: http://ajaxian.com/archives/innershiv-make-innerhtml-html5-work-in-ie, but it doesn't remedy the situation. The example I give above is of an element that's already on the DOM anyways.

+3  A: 

It's &apos; (and it does not work even using HTML4.01 DOCTYPE). Other HTML entities like &copy; &amp; etc work perfectly both IE7 and IE8.

&apos; does not work in IE (it's not because of HTML5 DOCTYPE, it's the same with other DOCTYPE). Also here they say it does not work, use &#39; as apostrophe

Marco Demajo
That's the ticket - thanks. Didn't even occur to me that it was apos; specifically.