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

  • Home
  • SEARCH
  • 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 5935175
In Process

The Archive Base Latest Questions

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

I have a confirm box on beforeload event – the code is as follows:

  • 0

I have a confirm box on beforeload event – the code is as follows:

window.onbeforeunload = function(){
            //alert('leaving ... ' + is_edited );

            if (is_edited == true) {
                return confirm('Are you sure you want to navigate away from this page? \n\n Press OK to continue, or Cancel to stay on the current page.');
            }

        };

The problem is that – the confirm alert is showing twice. I have searched on stackoverflow and got many questions about this issue. But mine is somewhat different. It is not the same confirm alert showing twice. For FF the message is same but for Crome in second confirm box the message is false.

Thanks in advance.

  • 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-22T15:13:01+00:00Added an answer on May 22, 2026 at 3:13 pm

    The “onbeforeunload” handler is supposed to return a string. Whether the string will be shown to the user or not is up to the browser.

    Your function returns the result of the “confirm()” call, a boolean. Firefox 4 does not show the returned string from the “beforeunload” handler, while other browsers still do. Thus your function puts up a “Confirm” box, gets the result, and returns it. The browser then puts up the “beforeunload” confirmation, which in the case of some browsers will include the stringified value returned from your handler (either “true” or “false”).

    Here is the Mozilla documentation for the event and its handler.

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

Sidebar

Related Questions

I want to have a confirm box when user tries to close the window.
I have this jquery code: $(#deletec-box).dialog({ autoOpen: false, resizable: false, height:230, modal: true, buttons:
I have a modal window, simulation JavaScript confirm box. Depending on button click i.e.,
I have put a confirm box on the logout option of my application. Code
I am developing the MooTools confirm box function. In which I have two buttons
I have a confirm box and redirect to an action but it is not
Is there a way to have a confirm dialog box display the value a
I have a popup confirm box which i am able to show like below.
I have a need for a confirm message box from a button click, but
How do I have a Javascript confirm() box with Yes or No instead of

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.