Skip to content

Instantly share code, notes, and snippets.

@c4urself
Created May 12, 2011 09:59
Show Gist options
  • Save c4urself/968270 to your computer and use it in GitHub Desktop.
Save c4urself/968270 to your computer and use it in GitHub Desktop.
HTML5 for Ajax loaded content in IE 7 and 8
// http://www.changer.nl
// http://jdbartlett.github.com/innershiv
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;
/*@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;
}
}());
jQuery.ajaxSetup({
dataFilter: function(data, dataType) {
if (typeof innerShiv === 'function' && (dataType === 'html' || dataType === undefined)) {
return innerShiv(data, false);
}
else {
return data;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment