我明白
SCRIPT601:此操作的源 HTML 无效。
ext-all-debug.js,第 6769 行第 21 行
在 IE 8 中
就是这条线。
el.insertAdjacentHTML(hashVal[0], html);
调试时,html中的值为"<a title=\"\">1</a>"
我被这个问题困扰了好几天。这与评级功能有关。我认为由于这个错误,评级星级在 ie 8 中不显示。其他浏览器没问题。 我在下面给出了相应的代码部分。我正在使用 extjs。
var starLink = star.createChild({
tag: 'a',
html: this.values[i],
title: this.showTitles ? this.titles[i] : ''
});
创建此元素时,调用将转到以下部分,并在上面指定的行上发生错误。
insertHtml : function(where, el, html){
var hash = {},
hashVal,
range,
rangeEl,
setStart,
frag,
rs;
where = where.toLowerCase();
hash[beforebegin] = ['beforeBegin', 'previousSibling'];
hash[afterend] = ['afterEnd', 'nextSibling'];
if (el.insertAdjacentHTML) {
if(tableRe.test(el.tagName) && (rs = insertIntoTable(el.tagName.toLowerCase(), where, el, html))){
return rs;
}
hash[afterbegin] = ['afterBegin', 'firstChild'];
hash[beforeend] = ['beforeEnd', 'lastChild'];
if ((hashVal = hash[where])) {
el.insertAdjacentHTML(hashVal[0], html);
return el[hashVal[1]];
}
} else {
最佳答案
IE 对于使用 .innerHTML、.insertAdjacentHTML 和类似的内容非常挑剔。
传递的 HTML 结构必须完美 - 不允许出现任何类型的错误。如果有的话,根本就做不到。其他浏览器将执行与文档其余部分相同的“最佳猜测”。
尝试输入一些非常简单的内容,例如 HTML 值:
<p>Hello World!</p>
你应该会发现它有效。在这种情况下,您需要找出您提供的 HTML 存在什么问题。如果它不起作用,那么您就会遇到另一个问题。
关于javascript - ie8 中此操作错误的源 HTML 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13820877/