Home > Client Side Programming > Do you want to close this window?

Do you want to close this window?


Sometimes you would want to close the window programatically using javascript:
window.close();.

There is a joke, I recall now, about Microsoft. A guy used a car and that car’s software was controlled by Microsoft Windows CR. One day that guy got frustrated at his work because of some stupid bug and was outrageously driving his car at top speed. Eventually his car became uncontrolable and he was about to bump in to the truck that was going before him. His cars air-bag was supposed to open now. Now the Microsoft Windows CR asked that guy a very smart question: Do you really want to open the air-bag? BANG!

Now, back to our problem: When you try to close an existing window programatically using javascript windows will behave very smart by asking the user: The web page you are viewing is trying to close the window. Do you want to close this window?

Now functinally,this window is supposed to be closed and user does not want to see this smart question asked by windows OS. What would you do?

Using the below code would not bring up that message:


function closeWithOutconfirm()
{
this.focus();
self.opener = this;
self.close();
}

Advertisements
  1. November 22, 2012 at 6:50 pm

    Hi, Neat post. There is a problem together with your site in internet explorer, might check this? IE nonetheless is the marketplace leader and a big portion of other people will leave out your magnificent writing due to this problem.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: