这与我的上一个问题类似,但问题不同。我使用单独的javascript文件来处理所有的javascript函数。该文件由我的主窗口调用,并且也由我的子窗口在另一个实例中调用。我的代码可以在除IE 9和10之外的所有浏览器中正常工作。我还没有测试早期版本的IE。
IE说有问题的行是window.opener.savetoparent($targetval);
。我的以前的代码是opener.savetoparent($targetval);
,在此之前我直接从子页面对父页面进行更改。我也进入了IE并启用了保护模式,如另一篇文章建议的那样,但行为没有改变。savetoparent()
对于子页面和父页面都是可用的,所以我必须使用opener来调用它以在父页面中运行。
我得到的错误是:无法获取未定义或空引用的'savetoparent'属性。
以下是代码:
function saveandclose($wintype, $propid) {
switch($wintype) {
case 'ccdetail':
var $targetval = $('#cc-total').val();
var $fieldname = 'closingcoststotal';
break;
}
window.opener.savetoparent($targetval);
closewindow();
}
安全的 parent 函数是:
function savetoparent($targetval) {
$('#' + $parentloc).val($targetval);
var $name = $('#' + $parentloc).attr("name");
var $rawtargetval = jsstrtonum($targetval);
processrvsave($propertyid, $name, $rawtargetval);
calcrvtotals();
}
任何您能提供的信息都将不胜感激。
窗口是这样启动的。
if(window.showModalDialog) {
window.showModalDialog($childname + '.php?ploc=' + $parentloc + '&propid=' + $propid, '', 'dialogWidth: ' + $winwidth + 'px; dialogHeight: ' + $winheight + 'px;')
}
else {
window.open($childname + '.php?ploc=' + $parentloc + '&propid=' + $propid, '', 'width=' + $winwidth + ', height=' + $winheight + ', modal=yes');
}
if(window.showModalDialog) {
window.showModalDialog($childname + '.php?ploc=' + $parentloc + '&propid=' + $propid, '', 'dialogWidth: ' + $winwidth + 'px; dialogHeight: ' + $winheight + 'px;') } else { window.open($childname + '.php?ploc=' + $parentloc + '&propid=' + $propid, '', 'width=' + $winwidth + ', height=' + $winheight + ', modal=yes'); } - bnorton