469,307 Members | 1,828 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,307 developers. It's quick & easy.

How do you access child window data from the parent window?

I have this onclose function for a window that in it it is suppose to grab data from the child window and store it the parent the parent then sends it via ajax to and jsp to store the data in a database. The code is shown below

Expand|Select|Wrap|Line Numbers
  1.  
  2. var auditpop;
  3.  
  4.  
  5.  
  6.     function auditPopup(){
  7.         var map = {"userid" : temp_user};
  8.         jQuery.ajax({
  9.             type: "GET",
  10.              url: '/auditwizard-portlet/checkInProgress.jsp',
  11.              dataType: "html",
  12.              data: map,
  13.              global: true,
  14.              success: function(responseHTML){
  15.                  var audit_war = "/auditwizard-portlet/view.jsp?userid=<%out.print(users);%>";
  16.                 auditpop = dhtmlmodal.open("auditbox","iframe",audit_war,"Athena Audit Wizard","width=1180px,height=700px,scrolling=1,center=0,top=5px,left=5px");
  17.                 auditpop.onclose =    function(){var audit_data = auditpop.document.getElementById("audit_main_div").innerHTML;
  18.                                                 var map = {"app" : auditpop.auditedApp
  19.                                                               , "user" : <%out.print(users);%>
  20.                                                               , "time" : auditpop.timestamp
  21.                                                               , "data" : audit_data};
  22.                                                 var save_url = "/auditwizard-portlet/SaveAuditToDB.jsp?random="+Math.floor(Math.random()*1000);
  23.                                                 jQuery.ajax({type: "GET",url: save_url,dataType: "html",data: map,global: true,
  24.                                                     success: function(responseHTML){
  25.                                                         alert("Save Successful");
  26.                                                     },
  27.                                                     error: function(xhr, status, e){
  28.                                                              if(xhr.status ==500){
  29.                                                                      alert("Please Contact Athena with error description");
  30.                                                              }else if(xhr.status == 404){
  31.                                                              }else{
  32.                                                                  alert("Error has occured with "+xhr.status);
  33.                                                              }
  34.                                                      }
  35.  
  36.                                                 });
  37.                                                 };                
  38.              },
  39.              error: function(xhr, status, e){
  40.                  if(xhr.status ==500){
  41.                      alert("Please Contact Athena with error descript");
  42.                  }else if(xhr.status == 404){
  43.                  }else{
  44.                      alert("Error has occured with "+xhr.status);
  45.                  }
  46.              }
  47.          });
  48.  
  49.  
Can anyone tell why this isn't working and/or how to fix it?
Feb 21 '12 #1
5 6300
Dormilich
8,651 Expert Mod 8TB
what part exactly isn't working?
Feb 22 '12 #2
The section of code in the onclose function where it is trying to gather information from the child window (auditpop). Mainly thr section of below.

Expand|Select|Wrap|Line Numbers
  1. {var audit_data = auditpop.document.getElementById("audit_main_div").innerHTML;
  2.                                                 var map = {"app" : auditpop.auditedApp
  3.                                                               , "user" : <%out.print(users);%>
  4.                                                               , "time" : auditpop.timestamp
  5.                                                               , "data" : audit_data};
  6.  
I have tried using alert to send back what it is getting and it keeps returning undefined. And before anyone asks (not meaning to be rude with my wording) yes the names of the div and the variables are correct, I have checked multiple times on that.

Can anyone tell why this isn't working?

Oh and the code it running in IE8 (if that helps)
Feb 22 '12 #3
Dormilich
8,651 Expert Mod 8TB
Oh and the code it running in IE8 (if that helps)
does it work in Firefox or Chrome?
Feb 22 '12 #4
I haven't checked because the overall application is only meant to run in IE. I used this site

http://www.codeproject.com/Articles/...window-or-vice

and it got to the point i am right now. But still it doesn't seem to work. Could it be that the child window is an iframe or something?

Also, I have my internet options set to allow almost anything and everything to occur for development purposes.
Feb 22 '12 #5
I think I have found the solution. It has to do with the fact that I am using dhtmlmodal window object. I cannot directly reference the window object (auditpop) in the onclose function instead i have to define it in reference to its content so i had to replace the auditpop in the onclose function with this.content. ...

Thank you for your replies.
Feb 22 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.