日期:2014-05-19  浏览次数:20763 次

js 对象不支持此属性或方法
   js运行到这一步 opener.selectCust(selectText,selectValue);报错,但是我已经定义了function selectCust() {}为什么啊,始终找不出原因
------最佳解决方案--------------------
引用:
你那个方法有形参么,好像没有把。

也可以的好不好
------其他解决方案--------------------
恩,是可以。
为啥不直接调用,而用opener.呢,这个好像不行。
------其他解决方案--------------------
把所有js都贴出来看看。
------其他解决方案--------------------
引用:
把所有js都贴出来看看。

function selectCustOk(){
var selectedcust = document.getElementById('selectedcust');
var selectText = "";
var selectValue = "";

for(var i=0; i<selectedcust.options.length; i++){
var temp = selectedcust.options[i].text.split('
------其他解决方案--------------------
');
if(selectText == ""){
selectText = temp[1];//selectedcust.options[i].text;
} else {
selectText = selectText + "," + temp[1];//selectedcust.options[i].text;
}
if(selectValue == ""){
selectValue = selectedcust.options[i].value;
} else {
selectValue = selectValue + "," + selectedcust.options[i].value;
}
}
opener.selectCust(selectText,selectValue);
window.close();
}



function unSelectCust(){
var unselectedcust = document.getElementById('unselectedcust');
if(!unselectedcust){
var htmlStr = '<select name="unselectedcust" multiple="multiple" style="width: 100%" size="20" ondblclick="dbClick(this);"></select>';
var norecd = document.getElementById("norecd");
norecd.innerHTML = htmlStr;
unselectedcust = document.getElementById('unselectedcust');
}
var selectedcust = document.getElementById('selectedcust');
if(selectedcust.selectedIndex == -1){
return;
}
for(var i=0; i<selectedcust.options.length; i++){
var selectText = selectedcust.options[i].text;
var selectValue = selectedcust.options[i].value;

if(selectValue==""){
selectedcust.options[i].selected = false;
continue;
}
if(selectedcust.options[i].selected){
var length = unselectedcust.options.length;
unselectedcust.options.add(new Option(selectText,selectValue));
unselectedcust.options[length].selected = true;
selectedcust.options.remove(i--);
}
}
}
------其他解决方案--------------------

function selectCust() {
var unselectedcust = document.getElementById('unselectedcust');
var selectedcust = document.getElementById('selectedcust');
if(unselectedcust.selectedIndex == -1){
return;
}
for(var i=0; i<unselectedcust.options.length; i++){
var selectText = unselectedcust.options[i].text;
var selectValue = unselectedcust.options[i].value;
if(selectValue==""){
unselectedcust.options[i].selected = false;
continue;
}