2
我想要做的是在已加載到頁面的<object>
內添加一個新的<param>
標記。這是因爲我試圖阻止對象的flash元素來到我所有下拉菜單的前面(添加wmode = opaque)。我想下面:將<param>元素添加到<object>
if (navigator.appName == 'Microsoft Internet Explorer')
{
var elements = document.getElementsByTagName('object');
var i =0;
for (i=0; i<elements.length ; i++){ //check all the objects in the page
var children = elements[i].childNodes;
var j = 0;
for (j=0 ; j<children.length; j++){
var paramname = children[j].name;
var paramvalue = children[j].value;
if (paramname=="movie" && paramvalue.indexOf("blahblah") != -1) { //this is the object i'm interested in
var newparam = document.createElement('param');
newparam.setAttribute('name', 'wmode');
newparam.setAttribute('value', 'opaque');
elements[i].appendchild(newparam); //this line causes the error
return;
}
}
}
}
運行腳本給我這個錯誤:"Object doesn't support property or method 'appendchild'" (Line: 22)
我到底做錯了什麼?
預先感謝您。
謝謝安德烈亞斯!掙扎了那麼多小時,我甚至沒有注意到。即使重寫代碼,我仍然用一個小的'c'來寫... – CrisDeBlonde 2012-01-12 15:05:43