Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  10] [ 7]  / answers: 1 / hits: 36925  / 12 Years ago, sat, december 29, 2012, 12:00:00

This is similar to my last question but the problem is different. I use a separate javascript file for all of my javascript functions. That file is called by my main window, and is also called in a separate instance by my child windows. My code works with every browser except IE 9 and 10. I have not tested earlier versions of IE.



IE says the offending line is window.opener.savetoparent($targetval); My previous code was opener.savetoparent($targetval); and before that I simply made the changes to the parent from the child directly. I have also gone into IE and enabled protected mode as suggested in another article with no change in behavior. Savetoparent() is available to both the child and the parent so I must call it with opener for it to run in the parent.



The error I am getting is : Unable to get property 'savetoparent' of undefined or null reference. Here is the code:



function saveandclose($wintype, $propid) {

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

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


The safe to parent function is:



function savetoparent($targetval) {
$('#' + $parentloc).val($targetval);
var $name = $('#' + $parentloc).attr(name);
var $rawtargetval = jsstrtonum($targetval);
processrvsave($propertyid, $name, $rawtargetval);
calcrvtotals();
}


Any light you can shed on this would be greatly appreciated.



window is launched like this



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

More From » jquery

 Answers
49

There is no opener in showModalDialog. Use the returnValue



Also there has not been a modal parameter on window.open in many years..



Here is how to use 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');
}


then



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();
}

[#81172] Thursday, December 27, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ednakarolinal

Total Points: 187
Total Questions: 106
Total Answers: 118

Location: Saint Helena
Member since Mon, Jan 16, 2023
1 Year ago
;