- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在下面的代码行中遇到错误:
var input2 = document.createElement('<input name=\'password\' type=\'password\' id=\'password\' onblur=\'checkCopy(this)\' onkeyup=\'return handleEnterSubmission(this.form,event)\' maxlength=\'16\' autocomplete=\'off\' onfocusin=\'checkValue(this.value, this.id);setMarginInIE();\' />');
在 IE8 中工作正常,但在 IE9 中出现问题。请告诉我这段代码有什么问题?
最佳答案
您的代码的主要错误是您显然从未阅读过 document.createElement()
的文档(例如 here )。
它说(强调我的):
var element = document.createElement(tagName);
element
is the created element object.tagName
is a string that specifies the type of element to be created. The nodeName of the created element is initialized with the value of tagName.
您无法将完整的 HTML 字符串传递给 createElement
。您可以传递标签名称:
var input2 = document.createElement('INPUT');
要创建完整的 HTML block ,请使用:
function createElementFromHTML(html) {
var temp = document.createElement('DIV');
temp.innerHTML = html;
return temp.childNodes[0];
}
关于IE9 中的 JavaScript 错误 :- SCRIPT5022: DOM Exception: INVALID_CHARACTER_ERR (5),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11674191/
This question is unlikely to help any future visitors; it is only relevant to a small geographic are
我在函数中有以下代码: this.HtmlRef = document.createElement( "canvas" ); if (!this.HtmlRef) { return
我使用新的 IE 9 测试了我的网站,但我收到错误消息 INVALID_CHARACTER_ERR (5)。在 IE 9 中,开发人员工具突出显示了这一行。谁能帮我解决这个错误? 错误行 this.i
我的用例:通过 jsoup 获取 html 页面并返回一个 w3c-DOM,以便通过 XML 转换进行进一步处理: ... org.jsoup.nodes.Document document = co
我正在写一个简单的待办事项列表。用户输入文本并将其添加为 checkbox。但是我收到了这个错误,我不知道这是怎么回事 INVALID_CHARACTER_ERR: DOM Exception 5 w
$('form#update').submit(function(){ var _data = $(this).serializeArray(); var param = {};
在下面的脚本中,IE9 会抛出一个错误: SCRIPT5022:DOM 异常:INVALID_CHARACTER_ERR (5)mootools-1.2.1-core-yc.js,第 118 行字符
我在执行肥皂请求时面临封送处理的问题。在soap UI上,它工作正常。当我应用ws安全性时会出现此问题。我正在使用Apache CXF-3.1.3。 以下是代码段。 final URL wsdlURL
我在下面的代码行中遇到错误: var input2 = document.createElement(''); 在 IE8 中工作正常,但在 IE9 中出现问题。请告诉我这段代码有什么问题? 最佳答案
当我在 IE9 中调试时,它在以下行中断 {var c=document.createElement('') 出现以下错误: SCRIPT5022: DOM Exception: INVALID_CH
我是一名优秀的程序员,十分优秀!