javascript confirm function ok and cancel return same result

后端 未结 1 656
傲寒
傲寒 2021-01-27 03:07

Here, I am calling confirm(param1, param2) method to display an alert Do you want to continue?

In this case, if the user clicks OK

相关标签:
1条回答
  • 2021-01-27 03:43

    There is no check!

    confirm(param1, param2);
    checkcount();
    

    and you want to change your function name to something other than confirm.

    <script>
    function call(param1, param2, param3)
    {
        if (condition)
        {
           /*some process */
        }
        else
        {
            if(myConfirm(param1, param2)) {
                checkcount();
            }
        }
    }
    
    function myConfirm(param1, param2)
    {
        if(condition)
        {
           var retVal = confirm("Do you want to continue ?");
           if (retVal == true)
           {
               alert("User wants to continue!");
               return true;
           } 
          else
          {
               alert("User does not want to continue!");
               return false;
          }
       }
    }
    </script> 
    
    0 讨论(0)
提交回复
热议问题