Closing a window when the parent is closed or exited.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Javilen
    New Member
    • Sep 2007
    • 20

    Closing a window when the parent is closed or exited.

    Hello,

    I am having trouble getting what should be simple to work.

    On my site we display peoples bills, we link to the companies website when viewing a specific link, this si done by passing the variables through a post/submit, the code is below.
    Code:
    <form name="frmBill" method="post" target="_SELF" action="www.someURL.com /printbill.do" onSubmit="Billing = window.open("Billing")">
    I use the Onsubmit portion to setup the window name.

    Now I have in the javascript section;
    Code:
    function closePage()
    		{
    		 if (Billing != null) Billing.close();
    		}
    And the portion that calls that is;

    Code:
    <body style="margin:0px" onunload=newWin.close();>
    Unfortunately This is not working, I have tried a number of variances found from other sites but I am having NO luck.

    Any ideas what I am doing wrong.
    Last edited by Javilen; Nov 18 '08, 04:01 PM. Reason: forgot the code tages
  • joedeene
    Contributor
    • Jul 2008
    • 579

    #2
    I'm not into JavaScript that much, but don't most newer/updated browsers have a feature that will prevent or ask the user if he wants the window closed, when JavaScript is trying to close the window?

    joedeene

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Try
      Code:
      <body ... onunload="closePage();">
      @joedeene, that's for windows not opened using JavaScript.

      Comment

      Working...