Hey all, I am getting some strange (at least to me!) behaviour from the javascript in a web application I am developing. There is a popup window with a form. Upon validation and submission, the information from the form is aggregated into a comma-separated string. This string is then passed to opener window by assigning the string (dataString) to the variable newUnitData:
window.opener.newUnitData = dataString; //in popup code
if(window.opener && !window.opener.closed) {
window.close();
}
In the opener window, the value of newUnitData is checked to see if it is empty or null. If not, some operations are performed on the string.
The problem I am observing is that unless an alert box is called just before any operations are performed on the string, then newUnitData is apparently empty. Upon subsequent operations (ie, another popup is opened, and the form submitted), then the newUnitData takes the values from the previous form.
From the opener window code:
createUnit = window.open('unitForm.aspx','createUnit','width=400,height=350,scrollbars=no');
createUnit.moveTo(400,400);
alert(); //if removed, newUnitData!='' evaluates to false (1st pass)
if(newUnitData != '' && newUnitData != null) {
newUnitData = newUnitData.slice(0,newUnitData.length-1);
....
Any clues as to what is causing this lag and/or any solutions? Although the code works as intended with the alert in place, it is obvious that it is annoying to the user to have to click through it. :)
thanks for any advice, christine