skip to Main Content

I am trying to disable click outside the confirm message in JS. Is there any simple solution for this issue? If the confirm message show up on mobile, and i click outside of it.. it will dissapear, but i need it to stay as it is.

 if (confirm("Are u sure?")) {
    
 }

I am also using this function in webview. Maybe there is a problem? Anyone have any suggestions?

EDIT: I found the problem is in the webview.
I am using AlertDialog builder and i do not calling the function setCanceledOnTouchOutside();

2

Answers


  1. Chosen as BEST ANSWER

    For anybody in the future, who is making jsAlert with builder. You just need to call .setCancelable(false) before .create(); in Android Studio project.


  2. You can use model to disable click outside. You want to set the backdrop value to static. You may also want to set the keyboard property to false because that prevents the modal from being closed

    In JS:

    $('#myModal').modal({
        backdrop: 'static',
        keyboard: false
    })
    

    or in HTML

    <div class="modal fade" id="myModal" data-keyboard="false" data-backdrop="static">
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search