brandonaaron/bgiframe — Issue #5: IE9 support: DOM Exception: INVALID_CHARACTER_ERR (5)
Author: palumine
Created: 2011-10-14 14:02:42+00:00
State: open

This error is explained in this post.
http://stackoverflow.com/questions/5344029/invalid-character-dom-exception-in-ie9

I could correct this error by replacing the html variable and creating the iframe element step by step, like this:

(function($) {

$.fn.bgIframe = $.fn.bgiframe = function(s) {
// This is only for IE6
if ($.browser.msie && /6.0/.test(navigator.userAgent)) {
s = $.extend({
top: 'auto', // auto == .currentStyle.borderTopWidth
left: 'auto', // auto == .currentStyle.borderLeftWidth
width: 'auto', // auto == offsetWidth
height: 'auto', // auto == offsetHeight

src: 'javascript:false;'
}, s || {});
var prop = function(n) { return n && n.constructor == Number ? n + 'px' : n; };

return this.each(function() {
if ($('> iframe.bgiframe', this).length == 0) {
var iframe = document.createElement("iframe");
iframe.setAttribute("class", "bgiframe");
iframe.setAttribute("frameborder", "0");
iframe.setAttribute("tabindex", "-1");
iframe.setAttribute("src", s.src);
iframe.style.setAttribute("display", "block");
iframe.style.setAttribute("position", "absolute");
iframe.style.setAttribute("z-index", "-1");
if (s.opacity !== false)
iframe.style.setAttribute("filter", "Alpha(Opacity='100') Mask()");

iframe.style.setAttribute("top", (s.top == "auto" ? "expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px')" : prop(s.top)));
iframe.style.setAttribute("left", (s.left == "auto" ? "expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px')" : prop(s.left)));
iframe.style.setAttribute("width", (s.width == "auto" ? "expression(this.parentNode.offsetWidth+'px')" : prop(s.width)));
iframe.style.setAttribute("height", (s.height == "auto" ? "expression(this.parentNode.offsetHeight+'px')" : prop(s.height)));

this.insertBefore(iframe, this.firstChild);
}
});
}
return this;
};
})(jQuery);

I Hope it helps.