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

Posted on 2006-05-17
Last Modified: 2008-02-26

I am very new to web development. I am using and Javascript and 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 :-)

Question by:resham
    LVL 28

    Expert Comment

    by:Pravin Asar
    You can not close a window which is not opened by javascript without  Confirmation  prompt

    This is for security purposes.


    LVL 28

    Accepted Solution

    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.location.href,'');">
    <input type="button" value="Close Parent Window" onClick="temp = window.opener.opener; window.opener.close(); window.opener = temp;">
    LVL 10

    Expert Comment

    Ah, close with popup replacement. I see.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    This article shows how to read a single webpage's HTML into a string variable, and it also shows how to automate a sequence so you can read and process a list of webpages.  I was tasked with reading and parsing a series of webpages to collect some s…
    JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
    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…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now