考慮此設置:無法添加到DOM有一個元素爲原型的onbject
function makeObj(a){
this.foo = 'bar';
this.prototype = a;
}
b = makeObj(document.getElementById('foo'));
document.getElementById('bar').appendChild(b);
這給出了一個錯誤:
Node cannot be inserted at the specified point in the hierarchy" code: "3
爲什麼會這樣?對象b
有一個有效的元素作爲其原型。它不應該有效嗎?
儘管瀏覽器在JavaScript中提供了DOM的接口,但DOM *不是JavaScript。 – 2012-01-07 09:39:19