www.webdeveloper.com
Results 1 to 5 of 5

Thread: disable close button on confrim() dialog

  1. #1
    Join Date
    Sep 2011
    Posts
    5

    Unhappy disable close button on confrim() dialog

    how can i disable the close(x) button on confirm dialog box in javascript

    if(window.confirm("Hello")){
    alert("Hi");
    }

  2. #2
    Join Date
    Sep 2011
    Posts
    1
    Why don't use alert, then you got only the "OK" button...

  3. #3
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by thaw View Post
    how can i disable the close(x) button on confirm dialog box in javascript

    if(window.confirm("Hello")){
    alert("Hi");
    }
    You can't. But you can use onbeforeunload if you want user to confirm he wants to leave the page.
    Code:
    window.onbeforeunload = function(e){
    var message = 'Are you sure you want to close the window/tab?';
    e=e||window.event; 
    e.returnValue = message;
    return message;
    }
    It won't work in Opera, but you should live with this

  4. #4
    Join Date
    Sep 2011
    Posts
    5
    Thanks Kor,
    i tried your code in my logoClick() function ,
    but it doesn't happen anything when i click button,
    please reply me, what is going wrong.
    thanks in advance.
    thaw.

    function logoClick()
    {
    window.onbeforeunload = function(e){
    var message = 'Are you sure you want to close the window/tab?';
    e=e||window.event;
    e.returnValue = message;
    return message;
    }
    }

  5. #5
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    I don't understand which is your final aim, really...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles