清除IE10中的innerHTML问题
Clearing innerHTML trouble in IE10
这是我的函数:
swPageProt.showContent = function () {
if (this._Parent) {
var container = this._Parent.getContentNode();
if (container) {
console.log(this._Content.innerHTML);
console.log(this._Parent.getContentNode().innerHTML);
container.innerHTML = '';
if (this._Content instanceof WT.BaseControl) {
this._Content.addToNode(container);
}
else if (this._Content.tagName) {
console.log(this._Content.innerHTML);
console.log(this._Parent.getContentNode().innerHTML);
container.appendChild(this._Content);
}
else {
container.innerHTML = this._Content + '' || '';
}
}
}
};
我想清除父容器并向其附加 this._Content
。这在 Chrome 和 Firefox 中工作正常,但 container.innerHTML = '';
行清除了 IE10 中的父实例和 this
实例。而且我总是得到带有空子 (this
) 内容的空父容器。如何在 IE10 中修复它?
已找到解决方案!
有必要使用 container.removeChild(container.firstChild);
而不是 container.innerHTML = '';
这是我的函数:
swPageProt.showContent = function () {
if (this._Parent) {
var container = this._Parent.getContentNode();
if (container) {
console.log(this._Content.innerHTML);
console.log(this._Parent.getContentNode().innerHTML);
container.innerHTML = '';
if (this._Content instanceof WT.BaseControl) {
this._Content.addToNode(container);
}
else if (this._Content.tagName) {
console.log(this._Content.innerHTML);
console.log(this._Parent.getContentNode().innerHTML);
container.appendChild(this._Content);
}
else {
container.innerHTML = this._Content + '' || '';
}
}
}
};
我想清除父容器并向其附加 this._Content
。这在 Chrome 和 Firefox 中工作正常,但 container.innerHTML = '';
行清除了 IE10 中的父实例和 this
实例。而且我总是得到带有空子 (this
) 内容的空父容器。如何在 IE10 中修复它?
已找到解决方案!
有必要使用 container.removeChild(container.firstChild);
而不是 container.innerHTML = '';