Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.open crashing ie

Status
Not open for further replies.
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???

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]
 
Is there some reason I can't have external script files in popup windows???

No reason at all.

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.

Perhaps you could post the code in question - it would be hard for us to comment without it!

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
This is everything in lib_ajax.js.

Could the problem be because I'm building the popup instead of calling the contents from a server? Since my src is a relative path instead of fully stated I'm wondering if ie is having a problem finding it sometimes???. I guess that doesn't make that much sense since it is working sporadically.

Thanx
Rois
----------------------------------------------------------------------------------

function sub(f,pairs,func) {
var file = '/index.php';
var SID = "";
if(func != "") {
func = "dsup="+func+"();&";
}
if(pairs=="") {
var str = "ajax=true&"+func+getFormValues(f,"");
} else {
if(document.getElementById('PHPSESSID')) {
SID = "PHPSESSID="+document.getElementById('PHPSESSID').value+"&";
}
str = "ajax=true&"+SID+func+pairs;
}
getXML(file,str);
}
function getXML(file,str,onDone) {
doc = null
if (typeof window.ActiveXObject != 'undefined' ) {
doc = new ActiveXObject("Microsoft.XMLHTTP");
} else {
doc = new XMLHttpRequest();
}
doc.open( "POST", file, true );
doc.setRequestHeader("Content-Type","application/x- charset=UTF-8");
doc.onreadystatechange = updatePage;
doc.send(str);
}
function getFormValues(fobj,valFunc) {
var str = "";
var valueArr = null;
var val = "";
var cmd = "";
for(var i = 0;i < fobj.elements.length;i++) {
switch(fobj.elements.type) {
case "text":
if(valFunc) {
cmd = valFunc + "(" + 'fobj.elements.value' + ")";
val = eval(cmd)
}
str += fobj.elements.name +
"=" + escape(fobj.elements.value) + "&";
break;
case "hidden":
if(valFunc) {
cmd = valFunc + "(" + 'fobj.elements.value' + ")";
val = eval(cmd)
}
str += fobj.elements.name +
"=" + escape(fobj.elements.value) + "&";
break;
case "select-one":
str += fobj.elements.name +
"=" + fobj.elements.options[fobj.elements.selectedIndex].value + "&";
break;
}
}
str = str.substr(0,(str.length - 1));
return str;
}
function updatePage() {
if (doc.readyState == 4) {
if (doc.status == 200) {
var response = doc.responseText.split("|");
if (response[0]!="") {
eval(response[0]);
}
} else if ((doc.status == 502) || (doc.status == 12031)) {
alert("Error Saving\n "+
"Try again\n"+
"Err("+doc.status+")");
} else {
alert("Status code " + doc.status+"\n"+
"Try again.");
}
}
}
 
I should probably mention, in case it's important, that the parent is a secure web page( -Rois
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top