By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,480 Members | 1,238 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,480 IT Pros & Developers. It's quick & easy.

Closing a window when the parent is closed or exited.

P: 20

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.
Expand|Select|Wrap|Line Numbers
  1. <form name="frmBill" method="post" target="_SELF" action=" /" onSubmit="Billing ="Billing")">
I use the Onsubmit portion to setup the window name.

Now I have in the javascript section;
Expand|Select|Wrap|Line Numbers
  1. function closePage()
  2.         {
  3.          if (Billing != null) Billing.close();
  4.         }
And the portion that calls that is;

Expand|Select|Wrap|Line Numbers
  1. <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.
Nov 18 '08 #1
Share this Question
Share on Google+
2 Replies

P: 583
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?

Nov 18 '08 #2

Expert Mod 15k+
P: 16,027
Expand|Select|Wrap|Line Numbers
  1. <body ... onunload="closePage();">
@joedeene, that's for windows not opened using JavaScript.
Nov 19 '08 #3

Post your reply

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