开发者

How to fix innerHTML on IE not rendering entities with HTML5 doctype?

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-mak开发者_如何学Pythone-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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜