這與我最後一個問題類似,但問題不同。我爲所有的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');
}
沒有你使用父頁面中的腳本打開子窗口? – mplungjan
是的,我做到了。它被打開一個模式窗口 – bnorton
代碼推出是\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