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 8888599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:05:00+00:00 2026-06-14T22:05:00+00:00

Maybe my question is very simple but i am new at HTML and JavaScript.

  • 0

Maybe my question is very simple but i am new at HTML and JavaScript.

I want to learn window.close() and window.stop() ,

So I tried it in a simple HTML page. But there is a problem, I am using my function in a tag. and window.stop() does not stop the operation. I want to stop the redirection if confirm dialog not true. How can I fix this problem?

HTML FILE:

<html>
<head>
    <title> My page </title>    
    <script src="my_javascript_file.js"></script>   
</head>
<body>

    <a href = "http://www.google.com" onclick="whereAreYouGoing()">Go</a>
    
</body>
</html>

my_javascript_file.js:

function whereAreYouGoing(){
    
    var exit = confirm("Are You Want to Sure to Leave?");
    
    if(exit){
        window.close();
    }
    
    else
        window.stop();

}
  • 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-06-14T22:05:01+00:00Added an answer on June 14, 2026 at 10:05 pm

    Try putting

     
      window.onbeforeunload = whereAreYouGoing;
     
    

    at the beginning of the javascript code.
    onbeforeunload always runs before a window is closed; so, if you wire the function to it, it’ll call the function before closing the window.
    Although that will display the dialog to the user before closing the window, all browsers gives the user the opportunity to override the function; this means that if the user wants to close the window, the browser will close the window, even if your function tries to prevent that from happening.

    Hope this helps.

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

Sidebar

Related Questions

Very simple, but maybe difficult to answer question. How do you include an AdvancedTableViewCells
Maybe this is a very simple question for you .NET guys but since I
This may be very simple question,But please help me. i wanted to know what
this may be a very simple question, but is it possible to force a
Very simple questions guys, but maybe I'm just forgetting something. In 64bit linux, a
Maybe a very simple question. How can I put in this code <Query> <Where>
I have what may be a very simple question. I want to process a
Maybe its a very dumb question but I hope you can give me some
Maybe the question sound not good or too simple. But not for me in
simple question maybe but can't find solution. I have button for refresh/update some contents

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.