Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 624949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:15:22+00:00 2026-05-13T19:15:22+00:00

How to close the current window from javascript without any events like onclick or

  • 0

How to close the current window from javascript without any events like onclick or something else..

   <script>
   window.close();
   </script>

The above doesnt seems top work..

Edit:
i am opening a child window from a parent window and after some operation i want to close the child window and window.close(); doesnt seem to work

Thanks..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:15:23+00:00Added an answer on May 13, 2026 at 7:15 pm

    Well, when do you want it to trigger? It will need some kind of event to trigger it, either on the document ready (if you want to close it immediately after opening it), or on some other event (a timer, a click, whatever).

    If you explain what you want to happen, it’s probably easy to solve.

    EDIT: Sorry, just checked it in FireBug, and Oded is correct. FireBug says scripts are not allowed to close windows that where not opened by script. But if it where, it should work…

    EDIT2: I used this code to open a new window:

    $(function(){
        window.open('/test2.html','test2','width=300,height=200');
    });
    

    And then the following in the newly opened window:

    <!DOCTYPE html>
    <html>
        <head>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
        </head>
        <body>
        <script type="text/javascript">
        $(function(){
            window.close();
        });
        </script>
        test
        </body>
    </html>
    

    This worked for me.

    EDIT3: Ripping out the jQuery and running the script in the body with no document ready checking also worked, but that might fail if you want to do anything other than closing the window. Any kind of document ready checking should work though. I just used jQuery because it’s simple… 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to close a popup window from an error page. The process is:
I am using finish() to close current activity before quit application in Android. However,
Is there a way to simply close a browser window, guaranteed ? Last time
For experimentation I've got a UIViewController and a custom window that intercepts touch events,
My problem is the following: In my javascript, I load an XML document from
I once tried to open a GLUT window from a sub-thread and got lots
I'm wondering whether it is possible to 'turn off' my main Window from loading
As close to the title as possible. I am very new to OOP (and
Open High Low Close Volume Adj Close Date 1990-01-02 00:00:00 35.25 37.50 35.00 37.25
Does it need manually close InputStream (bean.getContentAsStream()) in java after pass to Spring JDBC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.