appendChild无法在Chrome和Firefox中使用

时间:2014-11-03 14:15:44

标签: javascript

windowList.appendChild(text); ----文本未附加到文本区域(windowList)。任何人都可以帮助我....问题只出在Chrome和Firefox中。 IE8工作正常。

function Search(){
        var fieldType = document.forms[0].fieldName.value;
         document.forms[0].initialWindow.value = "";
         if(opener.document.getElementById(fieldType) != null){
             var windowList = opener.document.getElementById(fieldType);
             var popupList = document.getElementById("selectedList");
             var flagFound = false;
                var start = 0;
          for(i=0; i<popupList.length; i++){
                flagFound = false;
                for(j=start; j<windowList.length; j++){
                    if(windowList.value == popupList[i].value){
                    flagFound = true;
                    break;
                    }
                 }
              if(!flagFound){
                 var userName = popupList[i].text;
                 var index = userName.lastIndexOf("-");
                 userName = trim(userName.substring(0, index));
                     alert("userName>> "+userName);
                 var text = opener.document.createTextNode(';'+userName+';');
                 alert("text is "+text);
                 windowList.appendChild(text);  
                 }
            }
         }
    }

0 个答案:

没有答案