/ Published in: JavaScript
If you try to access innerHTML of HTML5 elements like or or even just the #foo id then IE returns nothing
innerShiv solves this.
innerShiv solves this.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// http://jdbartlett.github.com/innershiv | WTFPL License window.innerShiv = (function() { var d, r; return function(h, u) { if (!d) { d = document.createElement('div'); r = document.createDocumentFragment(); /*@cc_on d.style.display = 'none';@*/ } var e = d.cloneNode(true); /*@cc_on document.body.appendChild(e);@*/ e.innerHTML = h.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); /*@cc_on document.body.removeChild(e);@*/ if (u === false) return e.childNodes; var f = r.cloneNode(true), i = e.childNodes.length; while (i--) f.appendChild(e.firstChild); return f; } }());
URL: http://jdbartlett.github.com/innershiv