Chrome dismisses confirm() promps immediately without any user interaction










0















Some users of our website report that confirm dialog boxes appear, but immediately disappear, as if they are being dismissed automatically. This appears to be affecting Chrome only, not other browsers (not even Chromium).



Searching for similar issues finds many people complaining about confirm dialogs within onbeforeunload, but that is not my issue: this is not in that situation. The confirm dialog is shown when the page initially loads (triggered by jQuery $(document).ready()).



The Chrome documentation shows that confirm will not activate its tab and will be dismissed when the tab is switched from. That’s fine: the tab is already active (the confirm dialog appears on page load), and I am happy for it to be dismissed when the tab is switched from. The issue is that it’s being dismissed immediately, without any user interaction.



I found one similar report, but in that case the confirm prompts never appeared in the first place. It looks like what we’re seeing is something different.



$(document).ready(function() 
var c = confirm('Are you sure you wish to delete this entry?');
if (c)
$.ajax(
'/api/show/competition/delete',

'method': 'POST',
'data': 'id' : 9 ,
'dataType': 'json',
'complete': function(response, status)
if (response.responseJSON.error)
alert(response.responseJSON.message);
window.location.reload();
else
document.location.href = "/show/application/competition";



);
else
document.location.href = "/show/application/competition/entry/9";

);



We could use a jQuery modal window if necessary, but it seems silly to use an entire library to replace one line of code. And native browser alerts tend to look better in mobile browsers anyway.










share|improve this question
























  • Can you display our the problematic code?

    – Chayim Friedman
    Jul 9 '18 at 16:51











  • Silly of me not to include it. @חייםפרידמן. It's in now.

    – TRiG
    Jul 9 '18 at 16:54






  • 1





    Are you sure it is not a pop up blocker or chrome blocking it since no user action was triggered to show the prompt.

    – epascarello
    Jul 9 '18 at 16:55











  • In your link, the problem solved by removing some extensions and then restart the browser. Are you sure it isn't the problem in this issue (maybe they have ad blockers)?

    – Chayim Friedman
    Jul 9 '18 at 17:23















0















Some users of our website report that confirm dialog boxes appear, but immediately disappear, as if they are being dismissed automatically. This appears to be affecting Chrome only, not other browsers (not even Chromium).



Searching for similar issues finds many people complaining about confirm dialogs within onbeforeunload, but that is not my issue: this is not in that situation. The confirm dialog is shown when the page initially loads (triggered by jQuery $(document).ready()).



The Chrome documentation shows that confirm will not activate its tab and will be dismissed when the tab is switched from. That’s fine: the tab is already active (the confirm dialog appears on page load), and I am happy for it to be dismissed when the tab is switched from. The issue is that it’s being dismissed immediately, without any user interaction.



I found one similar report, but in that case the confirm prompts never appeared in the first place. It looks like what we’re seeing is something different.



$(document).ready(function() 
var c = confirm('Are you sure you wish to delete this entry?');
if (c)
$.ajax(
'/api/show/competition/delete',

'method': 'POST',
'data': 'id' : 9 ,
'dataType': 'json',
'complete': function(response, status)
if (response.responseJSON.error)
alert(response.responseJSON.message);
window.location.reload();
else
document.location.href = "/show/application/competition";



);
else
document.location.href = "/show/application/competition/entry/9";

);



We could use a jQuery modal window if necessary, but it seems silly to use an entire library to replace one line of code. And native browser alerts tend to look better in mobile browsers anyway.










share|improve this question
























  • Can you display our the problematic code?

    – Chayim Friedman
    Jul 9 '18 at 16:51











  • Silly of me not to include it. @חייםפרידמן. It's in now.

    – TRiG
    Jul 9 '18 at 16:54






  • 1





    Are you sure it is not a pop up blocker or chrome blocking it since no user action was triggered to show the prompt.

    – epascarello
    Jul 9 '18 at 16:55











  • In your link, the problem solved by removing some extensions and then restart the browser. Are you sure it isn't the problem in this issue (maybe they have ad blockers)?

    – Chayim Friedman
    Jul 9 '18 at 17:23













0












0








0


1






Some users of our website report that confirm dialog boxes appear, but immediately disappear, as if they are being dismissed automatically. This appears to be affecting Chrome only, not other browsers (not even Chromium).



Searching for similar issues finds many people complaining about confirm dialogs within onbeforeunload, but that is not my issue: this is not in that situation. The confirm dialog is shown when the page initially loads (triggered by jQuery $(document).ready()).



The Chrome documentation shows that confirm will not activate its tab and will be dismissed when the tab is switched from. That’s fine: the tab is already active (the confirm dialog appears on page load), and I am happy for it to be dismissed when the tab is switched from. The issue is that it’s being dismissed immediately, without any user interaction.



I found one similar report, but in that case the confirm prompts never appeared in the first place. It looks like what we’re seeing is something different.



$(document).ready(function() 
var c = confirm('Are you sure you wish to delete this entry?');
if (c)
$.ajax(
'/api/show/competition/delete',

'method': 'POST',
'data': 'id' : 9 ,
'dataType': 'json',
'complete': function(response, status)
if (response.responseJSON.error)
alert(response.responseJSON.message);
window.location.reload();
else
document.location.href = "/show/application/competition";



);
else
document.location.href = "/show/application/competition/entry/9";

);



We could use a jQuery modal window if necessary, but it seems silly to use an entire library to replace one line of code. And native browser alerts tend to look better in mobile browsers anyway.










share|improve this question
















Some users of our website report that confirm dialog boxes appear, but immediately disappear, as if they are being dismissed automatically. This appears to be affecting Chrome only, not other browsers (not even Chromium).



Searching for similar issues finds many people complaining about confirm dialogs within onbeforeunload, but that is not my issue: this is not in that situation. The confirm dialog is shown when the page initially loads (triggered by jQuery $(document).ready()).



The Chrome documentation shows that confirm will not activate its tab and will be dismissed when the tab is switched from. That’s fine: the tab is already active (the confirm dialog appears on page load), and I am happy for it to be dismissed when the tab is switched from. The issue is that it’s being dismissed immediately, without any user interaction.



I found one similar report, but in that case the confirm prompts never appeared in the first place. It looks like what we’re seeing is something different.



$(document).ready(function() 
var c = confirm('Are you sure you wish to delete this entry?');
if (c)
$.ajax(
'/api/show/competition/delete',

'method': 'POST',
'data': 'id' : 9 ,
'dataType': 'json',
'complete': function(response, status)
if (response.responseJSON.error)
alert(response.responseJSON.message);
window.location.reload();
else
document.location.href = "/show/application/competition";



);
else
document.location.href = "/show/application/competition/entry/9";

);



We could use a jQuery modal window if necessary, but it seems silly to use an entire library to replace one line of code. And native browser alerts tend to look better in mobile browsers anyway.







javascript google-chrome confirm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 15:08







TRiG

















asked Jul 9 '18 at 16:48









TRiGTRiG

7,11343984




7,11343984












  • Can you display our the problematic code?

    – Chayim Friedman
    Jul 9 '18 at 16:51











  • Silly of me not to include it. @חייםפרידמן. It's in now.

    – TRiG
    Jul 9 '18 at 16:54






  • 1





    Are you sure it is not a pop up blocker or chrome blocking it since no user action was triggered to show the prompt.

    – epascarello
    Jul 9 '18 at 16:55











  • In your link, the problem solved by removing some extensions and then restart the browser. Are you sure it isn't the problem in this issue (maybe they have ad blockers)?

    – Chayim Friedman
    Jul 9 '18 at 17:23

















  • Can you display our the problematic code?

    – Chayim Friedman
    Jul 9 '18 at 16:51











  • Silly of me not to include it. @חייםפרידמן. It's in now.

    – TRiG
    Jul 9 '18 at 16:54






  • 1





    Are you sure it is not a pop up blocker or chrome blocking it since no user action was triggered to show the prompt.

    – epascarello
    Jul 9 '18 at 16:55











  • In your link, the problem solved by removing some extensions and then restart the browser. Are you sure it isn't the problem in this issue (maybe they have ad blockers)?

    – Chayim Friedman
    Jul 9 '18 at 17:23
















Can you display our the problematic code?

– Chayim Friedman
Jul 9 '18 at 16:51





Can you display our the problematic code?

– Chayim Friedman
Jul 9 '18 at 16:51













Silly of me not to include it. @חייםפרידמן. It's in now.

– TRiG
Jul 9 '18 at 16:54





Silly of me not to include it. @חייםפרידמן. It's in now.

– TRiG
Jul 9 '18 at 16:54




1




1





Are you sure it is not a pop up blocker or chrome blocking it since no user action was triggered to show the prompt.

– epascarello
Jul 9 '18 at 16:55





Are you sure it is not a pop up blocker or chrome blocking it since no user action was triggered to show the prompt.

– epascarello
Jul 9 '18 at 16:55













In your link, the problem solved by removing some extensions and then restart the browser. Are you sure it isn't the problem in this issue (maybe they have ad blockers)?

– Chayim Friedman
Jul 9 '18 at 17:23





In your link, the problem solved by removing some extensions and then restart the browser. Are you sure it isn't the problem in this issue (maybe they have ad blockers)?

– Chayim Friedman
Jul 9 '18 at 17:23












2 Answers
2






active

oldest

votes


















2














I had exactly same issue. It seems like a chrome issue.



It requires a trick.
In my case, it worked by putting 0.1 sec delay with setTimeout function.



Try this. It will work.



function doConfirm() 
var c = confirm('Are you sure you wish to delete this entry?');
if (c)
$.ajax(
'/api/show/competition/delete',

'method': 'POST',
'data': 'id' : 9 ,
'dataType': 'json',
'complete': function(response, status)
if (response.responseJSON.error)
alert(response.responseJSON.message);
window.location.reload();
else
document.location.href = "/show/application/competition";



);
else
document.location.href = "/show/application/competition/entry/9";



$(document).ready(function()
setTimeout(function() doConfirm() , 100);
);





share|improve this answer






























    1














    In my case, the problem was caused by an iframe. I had a youtube video iframe, and the alert would close few milliseconds after showing. After removing the iframe, everything worked fine again.






    share|improve this answer
























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51250430%2fchrome-dismisses-confirm-promps-immediately-without-any-user-interaction%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      I had exactly same issue. It seems like a chrome issue.



      It requires a trick.
      In my case, it worked by putting 0.1 sec delay with setTimeout function.



      Try this. It will work.



      function doConfirm() 
      var c = confirm('Are you sure you wish to delete this entry?');
      if (c)
      $.ajax(
      '/api/show/competition/delete',

      'method': 'POST',
      'data': 'id' : 9 ,
      'dataType': 'json',
      'complete': function(response, status)
      if (response.responseJSON.error)
      alert(response.responseJSON.message);
      window.location.reload();
      else
      document.location.href = "/show/application/competition";



      );
      else
      document.location.href = "/show/application/competition/entry/9";



      $(document).ready(function()
      setTimeout(function() doConfirm() , 100);
      );





      share|improve this answer



























        2














        I had exactly same issue. It seems like a chrome issue.



        It requires a trick.
        In my case, it worked by putting 0.1 sec delay with setTimeout function.



        Try this. It will work.



        function doConfirm() 
        var c = confirm('Are you sure you wish to delete this entry?');
        if (c)
        $.ajax(
        '/api/show/competition/delete',

        'method': 'POST',
        'data': 'id' : 9 ,
        'dataType': 'json',
        'complete': function(response, status)
        if (response.responseJSON.error)
        alert(response.responseJSON.message);
        window.location.reload();
        else
        document.location.href = "/show/application/competition";



        );
        else
        document.location.href = "/show/application/competition/entry/9";



        $(document).ready(function()
        setTimeout(function() doConfirm() , 100);
        );





        share|improve this answer

























          2












          2








          2







          I had exactly same issue. It seems like a chrome issue.



          It requires a trick.
          In my case, it worked by putting 0.1 sec delay with setTimeout function.



          Try this. It will work.



          function doConfirm() 
          var c = confirm('Are you sure you wish to delete this entry?');
          if (c)
          $.ajax(
          '/api/show/competition/delete',

          'method': 'POST',
          'data': 'id' : 9 ,
          'dataType': 'json',
          'complete': function(response, status)
          if (response.responseJSON.error)
          alert(response.responseJSON.message);
          window.location.reload();
          else
          document.location.href = "/show/application/competition";



          );
          else
          document.location.href = "/show/application/competition/entry/9";



          $(document).ready(function()
          setTimeout(function() doConfirm() , 100);
          );





          share|improve this answer













          I had exactly same issue. It seems like a chrome issue.



          It requires a trick.
          In my case, it worked by putting 0.1 sec delay with setTimeout function.



          Try this. It will work.



          function doConfirm() 
          var c = confirm('Are you sure you wish to delete this entry?');
          if (c)
          $.ajax(
          '/api/show/competition/delete',

          'method': 'POST',
          'data': 'id' : 9 ,
          'dataType': 'json',
          'complete': function(response, status)
          if (response.responseJSON.error)
          alert(response.responseJSON.message);
          window.location.reload();
          else
          document.location.href = "/show/application/competition";



          );
          else
          document.location.href = "/show/application/competition/entry/9";



          $(document).ready(function()
          setTimeout(function() doConfirm() , 100);
          );






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jul 31 '18 at 0:47









          user3542241user3542241

          211




          211























              1














              In my case, the problem was caused by an iframe. I had a youtube video iframe, and the alert would close few milliseconds after showing. After removing the iframe, everything worked fine again.






              share|improve this answer





























                1














                In my case, the problem was caused by an iframe. I had a youtube video iframe, and the alert would close few milliseconds after showing. After removing the iframe, everything worked fine again.






                share|improve this answer



























                  1












                  1








                  1







                  In my case, the problem was caused by an iframe. I had a youtube video iframe, and the alert would close few milliseconds after showing. After removing the iframe, everything worked fine again.






                  share|improve this answer















                  In my case, the problem was caused by an iframe. I had a youtube video iframe, and the alert would close few milliseconds after showing. After removing the iframe, everything worked fine again.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Sep 6 '18 at 17:49

























                  answered Sep 6 '18 at 13:36









                  soc.efssoc.efs

                  437




                  437



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51250430%2fchrome-dismisses-confirm-promps-immediately-without-any-user-interaction%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      這個網誌中的熱門文章

                      How to read a connectionString WITH PROVIDER in .NET Core?

                      Museum of Modern and Contemporary Art of Trento and Rovereto

                      In R, how to develop a multiplot heatmap.2 figure showing key labels successfully