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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:15:20+00:00 2026-06-11T05:15:20+00:00

I have allowed the user to make some changes in form fields and based

  • 0

I have allowed the user to make some changes in form fields and based on whether a user has made some changes, I enable the “Submit Changes” button.

I want to add a feature where I ask the user to confirm that he wants to navigate to some other page without submitting the changes done by him. I have added the code to show a dialog box but the problem is that the dialog is shown for small period and then page navigation moves to another page. My code is:

        window.onbeforeunload = function() {
            if(!dijit.byId('editBtn').get('disabled')) {
                discardChanges(
                        'Pending Unsaved Changes',
                        'You have pending unsaved changes. Do you really want to discard them?',
                        'Discard Changes',
                        function() {
                            return true;
                        },
                        function() {
                            return false;
                        },
                        300,
                        700);
            }
        }

How do I stop the browser from moving to other page and wait for user to click a button on the dialog box and then decide if click is to be discarded or not. The dialog box looks like:

enter image description here

  • 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-11T05:15:21+00:00Added an answer on June 11, 2026 at 5:15 am

    Too many sites has abused this functionality so for security reasons browsers had added counter measures.

    Opera don’t support the event. Modern versions of Firefox only shows a standardized native message. Chrome, Safari and IE shows both a native message and the custom message returned from the function. As far as I know, you can’t stop the event.

    I suggest that you instead save the changes as a draft. Be aware that Opera don’t support the event, so you might need to save the changes according to a timer. By saving it as a draft by a timer, you will as a bonus also be able to let the user return and continue after a browser crash.

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

Sidebar

Related Questions

I have a list of the user's images displayed, (who has already allowed access
I have an application where a user is allowed to save some text data
I have a requirement that a user is allowed only to enter string value
Why to restrict allowed usernames by different rules? For example why can't user have
I have spent days trying to make this work based on the examples in
I have made some helper functions that run a simulation using a lot of
I have a templated function fct that uses some complex data structure based on
I have the following situation: A patient is allowed to make 2 online appointments
Am I allowed to have a directory named 'import' containing Python code? Or will
Should a Singleton class be allowed to have children? Should we seal it? What

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.