0

I have some simple javascript that I want to run on a contact page it should display a pop-up when the page loads, and a different pop-up when the user navigates away.

The code I have below works fine on IE but on chrome the onunload part doesn't work at all.

Is there any work-around for this?

 <script>
          window.onload = function(){
              alert('Even if you aren\'t interested, please give our design some feedback as we would like to stay current.');
              return;
          }
          window.onunload = function(){
              alert('Thank you for your time and consideration');
              return;
          }
    </script>
Callat
  • 2,928
  • 5
  • 30
  • 47
  • http://stackoverflow.com/questions/7794301/window-onunload-is-not-working-properly-in-chrome-browser-can-any-one-help-me – Asons Apr 23 '17 at 22:19
  • 1
    Possible duplicate of [window.onunload is not working properly in Chrome browser. Can any one help me?](http://stackoverflow.com/questions/7794301/window-onunload-is-not-working-properly-in-chrome-browser-can-any-one-help-me) –  Apr 23 '17 at 22:20

1 Answers1

0

Try:

window.onload = function(){
          alert('Even if you aren\'t interested, please give our design some feedback as we would like to stay current.');
          return;
      }
      window.beforeunload = function(){
          alert('Thank you for your time and consideration');
          return;
      }