open new window after cancel confirmation in Java Script : i want when the user clicks on closing the web page window /tab a cancel confirmation should come up and when the users click "OK" the current page closes and a new window in opened, this is what i've dine so far and it doesn't work:


         function confirmit(){
             var closeit= confirm("شكراً لك :) فقط نرجوا القليل من وقتك لتعبئة الاستبانة");
             if (closeit == true){
                 window.open("https://www.surveymonkey.com/r/3DMJGYX", "الاستبانة");} 
             else{
                 window.close();}}
         window.onbeforeunload = function(){
                        $.ajax({
                           type: 'GET',
                           url: 'http://gadgetron.store/chatbot/run_python_clear_chatM/',});
                        confirmit();
                }

Thank you,