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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:34:46+00:00 2026-06-02T20:34:46+00:00

I have this code: $(window).bind(‘beforeunload’, function () { $(#dialogsendnotifications).dialog(‘open’); }); $(#dialogsendnotifications).dialog({ autoOpen: false, closeOnEscape:

  • 0

I have this code:

$(window).bind('beforeunload', function () {

        $("#dialogsendnotifications").dialog('open');
    });

    $("#dialogsendnotifications").dialog({

        autoOpen: false,
        closeOnEscape: false,
        buttons: {
            "Yes": function () {
                $(this).dialog('close');
            },
            "No": function () {
                $(this).dialog('close');
            }
        }
    });

So basically what it does is when the user tries to navigate away it pops up the yes no dialog. The troub is that the dialog comes up but it navigates away from the page before the user even gets to choose a button.

Can someone please tell me how to get it to wait until the user has selected an answer?

  • 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-02T20:34:48+00:00Added an answer on June 2, 2026 at 8:34 pm

    You can’t. The onbeforeunload event is very, very restrictive. All you can do is return a string which the browser will then use in its own dialog. You can’t do anything fancy at all.

    Here’s an example: Live copy | source

    jQuery(function($) {
    
      $(window).bind("beforeunload", function(event) {
        return "This is the message you're allowed to provide";
      });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this little piece of code: <script> $(window).bind('beforeunload', function() { $.ajax({ async: false,
I have this jQuery code; $(function () { $(window).unbind(beforeunload); $(window).bind(beforeunload, function () { return
I have this form submit code: Event.observe(window, 'load', init, false); function init() { Event.observe('addressForm',
I have this code. $(document).ready(function() { $('#box').hide(); $(window).bind('scroll', function(){ if($(this).scrollTop() > 200) { $(#box).fadeIn(300);
jQuery('img').bind('error',function(){ alert('hi'); jQuery(this).hide(); }); I have written this code but non available images are
I have this code: public class Window extends JFrame { public Window(){ ... JButton
I have this code which draws a Window and NSView, and have set up
I have this code: $(div[id^='intCell']).mouseover(function() { $(this).css({ border:,1px solid #ff097c}); }).mouseout(function() { $(this).css({border:,1px solid
I have this code: document.getElementById('img'+i).onclick = function(){popup_show('popup',array_msg[i]+'|||'+date('Y-m-d',strtotime(lec_date))+'-==-'+str_view_forConflict, 'AddEditSchedule;;popup_drag2;;EditSched;;'+String(array_msg_id[3])+';;view', 'popup_drag', 'popup_exit', 'screen-center', 0, 0);}; ...but
I have this code: $(document).ready(function() { var number = 10; var offset = 10;

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.