将<param />元素添加到<object> </object>

时间:2012-01-12 14:58:21

标签: javascript html dom

我要做的是在已加载到页面的<param>中添加新的<object>标记。这是因为我试图阻止对象的flash元素进入我的所有下拉菜单(添加wmode = opaque)。我正在尝试以下方法:

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)
我究竟做错了什么?

提前谢谢。

1 个答案:

答案 0 :(得分:3)

你试过大C

elements[i].appendChild(newparam);