2012-12-29 132 views
2

这与我最后一个问题类似,但问题不同。我为所有的javascript函数使用单独的JavaScript文件。该文件由我的主窗口调用,并且也在我的子窗口的单独实例中调用。我的代码适用于除IE 9和10以外的所有浏览器。我没有测试早期版本的IE。无法获取未定义或空引用的属性

IE说有罪行是window.opener.savetoparent($targetval);我以前的代码是opener.savetoparent($targetval);,在此之前我直接对孩子进行了修改。我也进入了IE并启用了保护模式,正如另一篇文章中提到的那样,行为没有变化。 Savetoparent()对孩子和父母都是可用的,所以我必须用opener调用它才能在父母中运行。

我得到的错误是:Unable to get property 'savetoparent' of undefined or null reference.这里是代码:

function saveandclose($wintype, $propid) { 

switch($wintype) { 
    case 'ccdetail': 
     var $targetval = $('#cc-total').val(); 
     var $fieldname = 'closingcoststotal'; 
     break; 
} 

window.opener.savetoparent($targetval); 
closewindow(); 
} 

的安全父功能是:

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'); 
} 
+0

没有你使用父页面中的脚本打开子窗口? – mplungjan

+0

是的,我做到了。它被打开一个模式窗口 – bnorton

+0

代码推出是\t 如果(window.showModalDialog){ \t \t window.showModalDialog($ childname +名 '.php?PLOC =' + $ parentloc + '&PROPID =' + $ PROPID, '', 'dialogWidth:' + $ winwidth + 'PX; dialogHeight:' + $ winheight + 'PX;') \t}否则{ \t \t window.open($ childname + '.PHP PLOC ='? + $ parentloc +'&propid ='+ $ propid,'','width ='+ $ winwidth +',height ='+ $ winheight +',modal = yes'); \t} – bnorton

回答

2

中有没有在showModalDialog开门红。使用的returnValue

而且还没有在多年来一直模态参数上window.open ..

这里是如何使用的returnValue

if(window.showModalDialog) { 
    $targetval = window.showModalDialog($childname + '.php?ploc=' + $parentloc + '&propid=' + $propid, 
    window, 
    'dialogWidth: ' + $winwidth + 'px; dialogHeight: ' + $winheight + 'px;')) 
    if(targetval) savetoparent($targetval); 
} 
else { 
    window.open($childname + '.php?ploc=' + $parentloc + '&propid=' + $propid, '', 'width=' + $winwidth + ', height=' + $winheight + ', modal=yes'); 
} 

然后

function saveandclose($wintype, $propid) { 
    var $targetval =""; 
    switch($wintype) { 
    case 'ccdetail': 
     $targetval = $('#cc-total').val(); 
     // var $fieldname = 'closingcoststotal'; I do not see this used anywhere 
     break; 
    } 

    if (window.opener) window.opener.savetoparent($targetval); 
    else returnValue = $targetval; 
    closewindow(); 
} 
+0

谢谢。这工作。 – bnorton

相关问题