• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1166
  • Last Modified:

How to close previous window without confirmation box? or take off toolbar,menubar from current window - urgent please


I am very new to web development. I am using asp.net and Javascript and vb.net as a code behind

I am opening a new window without toolbar and menubar once user clicks on the button.
Now I want to close previous window. But when I say window.close(), it asks me confirmation message.

Now I cannot use location.Replace() because I dont want menubar and toolbar for the new URL.

So how do i do it?
How can you close a window without confirmation? Or how to take off menubar and toolbar off from current window?

Any comments welcome :-)

  • 2
1 Solution
Pravin AsarCommented:
You can not close a window which is not opened by javascript without  Confirmation  prompt

This is for security purposes.


Pravin AsarCommented:
Here is simple example , which demos my previous post

Save following code in a htm file .

<title>Open/Close Windows</title>

<script language="javascript">
if (window.opener) {
     alert ('Parent ' + window.opener);
if (window.opener.opener) {
     alert ('GrandParent ' + window.opener);
This is a test page.
<br>1. Click on "Open Window."
<br>This opens same document on new window.
<br>2. Click on "Open Window" in newly window.
<br>This opens same document on another window.
<br> This window has parent and grandparent.
<br> Click on "Close Window". This will close the this parent and reassigns the
<br> parent as GrandParent.
<input type="button" value="Open Window" onClick="window.open (window.location.href,'');">
<input type="button" value="Close Parent Window" onClick="temp = window.opener.opener; window.opener.close(); window.opener = temp;">
Dennis MaederCommented:
Ah, close with popup replacement. I see.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now