?
Solved

Child window target not working.

Posted on 2003-03-23
3
Medium Priority
?
233 Views
Last Modified: 2012-06-21
<html>
     <head>
     <title>This is open pop-up</title>
     <script language="Javascript" >

     var childwin;
     var popupName;
     window.name = "PurchasePage";

     function OnLoadEvent()
     {
          childwin = window.open('',"PurchasePagePopup",'height=400,width=390,status=yes,dependent=no,scrollbars=yes,screenX=500,screenY=250,left=450,top=150');
          childwin.focus();          
          document.downloadForm.submit();
          }

     </script>
     </head>
     <body onload="OnLoadEvent();" >
     <form name="downloadForm" action="acsURL.html" method="POST" target="PurchasePagePopup">
          <input type="hidden" name="PaReq" value="true">
          <input type="hidden" name="TermUrl" value="opodo.jsp">
     </table>
     </form>
</body>
</html>

I am using this code to open a pop and set the parent windows target to a pop-up. Sometimes it opens 3 windows, instead of two.

The 3 windows being, parent window,another child pop window, and third the window coming out of the target. This happens only some time. I dont understand, when I am setting the parent windows target as the child window, why the response is displayed in a new window and not the child pop-up.

Please help me out.

Regards
OM





0
Comment
Question by:osingh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Accepted Solution

by:
gator4life earned 300 total points
ID: 8193882
I think the reason you may be having a problem is due to the timing of the scripts you are using.  If the popup window finishes loading before the submit fires, then the target knows where to go, since the new windows name has been set.  If the popup window does not finish loading before the submit fires, then the target does not think the new window is there, and thus creates another window.

Here is what I would do to completely solve this problem.  Create a small file that will temporarily be loaded into the pop-up window when it is first loaded.  This small file will only contain one JavaScript function that will fire when the onload event of the <body> of that file is triggered.  Therefore, the function in the small file will only run when the window has completely loaded, ensuring that the pop-up windows name is set and ready to be targeted.  This function will then refer back to the parent page and submit the form.

Here is what I explained above shown in code:

==========================================================
Parent Page
==========================================================

<html>
     <head>
          <script type="text/javascript">
          <!--
               var oChildWin;

               function OnLoadEvent() {

                    oChildWin = window.open('tempPage.html', 'PurchasePagePopup', 'height=400,width=390,status=yes,dependent=no,scrollbars=yes,screenX=500,screenY=250,left=450,top=150');
               }
          //-->
          </script>
     </head>
     <body onload="OnLoadEvent()">
          <form name="downloadForm" action="acsURL.html" method="post" target="PurchasePagePopup">
               <input type="hidden" name="PaReq" value="true">
               <input type="hidden" name="TermUrl" value="opodo.jsp">
          </form>
     </body>
</html>

==========================================================
tempPage.html
==========================================================

<html>
     <head>
          <script type="text/javascript">
          <!--
               function SubmitParentForm() {
                   
                    window.opener.document.forms('downloadForm').submit();
               }
          //-->
          </script>
     </head>
     <body onload="SubmitParentForm()">
          <br>
     </body>
</html>

==========================================================

Try this out and see if it works.  Let me know if you have any questions.

gator4life
(chomp, chomp)
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10149631
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: gator4life {http:#8193882}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question