2

I want to open a survey link on winow/tab close and on url change with confirmation box Ok/Cancel. Need to redirect user to survey link on Ok button click. I am using the code as follows:

function ConfirmClose(e) {
   if (!e) e = window.event;   
   e.cancelBubble = true;

   if (e.stopPropagation) {
    e.stopPropagation();
    e.preventDefault();
   }
   if (e.clientY < 0)
   {
    var leave_message ="Wait! Would you like to respond to a quick Survey";
    if (confirm(leave_message)) {
    window.open("www.surveylink.com");
    }
  }
}

window.onbeforeunload = ConfirmClose;

Its working fine in i.e. 8,9. But not work in firefox, chrome and higher version of i.e. Please suggest.

MChauhan
  • 21
  • 1

1 Answers1

0

Check Armins answer on window.onunload is not working properly in Chrome browser. Can any one help me? , Chrome inhibits some functions during the onunload event that are also confrim boxes. You can popup a dialog by just returning a String which then cann be confirmed/canceld which retuns into page leave/stay.

Community
  • 1
  • 1
Smi Lee
  • 138
  • 7