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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:31:17+00:00 2026-05-23T04:31:17+00:00

I am displaying a warning dialog box on window close event. If user clicks

  • 0

I am displaying a warning dialog box on window close event. If user clicks on Cancel control stays on same page or if user clicks on Okay he get navigated to desired page.
I want collect the value of dialog box means whether user have clicked on Cancel or Okay.I have written following code in external JavaScript:

    $(document).ready(function()
    {
        window.onbeforeunload = askConfirm;
        
        function askConfirm()
        {
            if (flag)
            {
                // Message to be displayed in Warning.
                return "Your unsaved data will be lost.";
            }       
        } 
    }  

How can I collect the value?

  • 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-23T04:31:18+00:00Added an answer on May 23, 2026 at 4:31 am
    <script type="text/javascript">
    
                window.onbeforeunload = function (evt) {
    
                    return "Are you sure to close?";
    
                }
    
            </script>
    

    example code

    http://files.dropbox.com/u/642364/blogger/scripts/close.html

    EDIT
    Getting the response code from the user on window close

    <body onUnload = "CheckIt ()" >
    ...
    </body>
    <script>
    function CheckIt ()
    {
      var response = confirm ("Are you closing..");
       alert (response); // do whatever for response.
    
    }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am displaying a warning message if user try to close window without saving
I am displaying a warning dialog box whenever user tries to navigate from current
http://www.neighborrow.com is currently displaying this error: Warning (512): SQL Error: 1054: Unknown column 'User.rating'
Displaying Type here to ... until the user enters text into a TextBox is
I am displaying a scrolled data table in a web page. This table has
I have used Multiple select Box in edit form, displaying previously selected items in
In my application, when the user clicks an infoButton, it should add another view
I´m displaying images in a ListBox and i want to control the size (small,
i have a php page While running it will display following messages Warning: mysql_select_db()
When displaying the value of a decimal currently with .ToString() , it's accurate to

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.