Javascript:DOM 异常:INVALID_CHARACTER_ERR (5)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6169901/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javascript: DOM Exception: INVALID_CHARACTER_ERR (5)
提问by Brad Wickwire
I tested my site with the new IE 9 and I get the error telling me INVALID_CHARACTER_ERR (5). In IE 9, the developer tools highlights this line. Can anyone help me with this error?
我用新的 IE 9 测试了我的网站,我收到错误消息,告诉我 INVALID_CHARACTER_ERR (5)。在 IE 9 中,开发人员工具突出显示了这一行。谁能帮我解决这个错误?
Error Line
错误行
this.iframe = document.createElement('<IFRAME src="' + myCurrentUrl + '" frameborder=0>');
Function Code
__createDivs : function()
{
this.divs_transparentDiv = document.createElement('DIV');
this.divs_transparentDiv.className='modalDialog_transparentDivs';
this.divs_transparentDiv.style.left = '0px';
this.divs_transparentDiv.style.top = '0px';
document.body.appendChild(this.divs_transparentDiv);
this.divs_content = document.createElement('DIV');
this.divs_content.className = 'modalDialog_contentDiv';
this.divs_content.id = 'DHTMLSuite_modalBox_contentDiv';
this.divs_content.style.zIndex = 100000;
if(this.MSIE){
var myCurrentUrl = GlobPanelCurrentBaseUrl + 'images/spacer.gif';
this.iframe = document.createElement('<IFRAME src="' + myCurrentUrl + '" frameborder=0>');
this.iframe.style.zIndex = 90000;
this.iframe.style.position = 'absolute';
document.body.appendChild(this.iframe);
}
document.body.appendChild(this.divs_content);
this.divs_shadow = document.createElement('DIV');
this.divs_shadow.className = 'modalDialog_contentDiv_shadow';
this.divs_shadow.style.zIndex = 95000;
document.body.appendChild(this.divs_shadow);
window.refToModMessage = this;
this.addEvent(window,'scroll',function(e){ window.refToModMessage.__repositionTransparentDiv() });
this.addEvent(window,'resize',function(e){ window.refToModMessage.__repositionTransparentDiv() });
}
回答by onteria_
Yes, you're supposed to just give it the name of the element, then set properties on it like so:
是的,你应该只给它元素的名称,然后像这样设置它的属性:
this.iframe = document.createElement('iframe');
this.iframe.src = myCurrentUrl;
this.iframe.frameBorder = 0;