Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lag in passing values from popup to opener?

    Hey all,
    I am working on an application that has a popup form. When the form is submitted, the values in the form are passed to a variable in the opener window code. The popup is closed and focus returned to the opener.

    The problem that seems to arise for me is that the new value for the variable is only set after a 'lag' in the code; it only updates if I display an alert box after focus is returned to the opener. If I don't display the alert box, then in the first occurrence, the variable stays blank. Subsequent events result in the variable having the value of the popup window previously submitted, not the last one, as expected. Testing in Opera (was told as long as the application works in one browser, it's okay - experimental phase )

    Relevant code snippets below. Any suggestions/fixes?
    Thanks for your help!

    Main Code (createUnit is a global variable):
    Code:
    createUnit=window.open('unitForm.aspx','createUnit','width=400,height=300,scrollbars=no');
    if(window.focus){
           alert(newUnitData); //this prevents the lag; if removed, lag occurs.
     }
    if(newUnitData != '') {
    do stuff }
    Popup Code (dataString is a global variable):
    Code:
     //this function is called when the form is submitted
    function submitUnit() {
              var numElements = document.forms['newUnit'].elements.length;
              for(i=0;i<numElements-1;i++){
                    dataString += document.forms['newUnit'].elements[i].value + ',';
        	   }
        	  if(window.opener && !window.opener.closed) {
        	       window.opener.newUnitData = dataString;
        	       window.close();
        	  }
           }
    Last edited by pupurun; 07-15-2009 at 09:20 AM. Reason: clarification


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •