gimecoffee
MIS
- Mar 3, 2006
- 25
I need to open multiple child windows and have them close if the parent closes or browses away. Here is the essence of the code I'm using. The showreg function can be call multiple times for various 'type,code' and I'm re-using the same window name (win1234) for all the popups so I can make sure they are closed if the parent closes. My problem is that at random times running the showreg function crashes ie and usually I'll have to reboot windows. When it crashes, the popup will open and then lockup with about:blank in the title bar. Of coarse there are many more 'win151122.document.write()' statements with various window formatting stuffs. This has all been working fine until recently when I started having the child window send changes made in the child back to arrays in the parent. Also new is ajax scripts(external) in the child to update the originating database before closing the child. The part '<script src="/weblib/lib_ajax.js"><\/script>' appears to be my problem since when I comment it out it appears to work without problems.
Is there some reason I can't have external script files in popup windows???
Is there some reason I can't have external script files in popup windows???
Code:
<script>
var win151122;
function closeDep() {
if (win151122 && win151122.open && !win151122.closed) { win151122.close(); }
}
function showreg(type,code) {
if (win151122 && win151122.open && !win151122.closed) {
win151122.close();
}
var width=325; var height=350; var left=400; var top=175;
win151122=window.open('','',
'width='+width+',height='+height+',left='+left+',top='+top+',screenX=0,screenY=0,'+
'location=0,menubar=0,resizable=1,scrollbars=0,status=0,titlebar=0');
win151122.document.write('<body>'+
'<script src="/weblib/lib_ajax.js"><\/script>'+
'<form id="form1" name="form1">'+
'<input type="text" id="ytd_accrual" name="ytd_accrual" '+
'value="'+prt[type][code]['ytd_accrual']+'"><br>');
win151122.document.write('<button TYPE=\'button\' '+
'onclick="opener.prt[\''+type+'\'][\''+code+'\'][\'ytd_accrual\']'+
'=document.getElementById(\'ytd_accrual\').value;'+
'/*sub(this.form,\'\',\'ajax_prt_save\');*/window.close();">Save & Close</button>');
win151122.document.write('<\/form><\/BODY>');
win151122.document.close();
win151122.focus();
}
</SCRIPT>
<body onUnload="closeDep();">
<script>
prt = new Array();
prt['A'] = new Array();
prt['A']['01'] = new Array();
prt['A']['01']['ytd_accrual']='25';
</script>
<a href="" onclick="showreg('A','01'); return false;">A01</a>
</body>
[code]