On Exit SCRIPT

by 4 replies
5
I need a script that will redirect users to an EXIT page before they actually exit.

I tried using...

<!-- Exit script -->

<script language=javascript>
window.onbeforeunload = function () {
window.location = 'http://www.website.com/page.html';
return false;
}
</script>

<!-- -->


but for some reason even the RELATIVE links are redirecting me to the exit page.

Need help

Thanks
#website design #exit #script
  • [DELETED]
    • [ 1 ] Thanks
    • [1] reply

    • That worked! Awesome! thanks everyone!

      Here is the CODE that I used that worked!

      <script language="javascript">
      (function() {
      setTimeout(function() {
      var __redirect_to = 'http://www.DOMAIN.com';//

      var _tags = ['button', 'input', 'a'], _els, _i, _i2;
      for(_i in _tags) {
      _els = document.getElementsByTagName(_tags[_i]);
      for(_i2 in _els) {
      if((_tags[_i] == 'input' && _els[_i2].type != 'button' && _els[_i2].type != 'submit' && _els[_i2].type != 'image') || _els[_i2].target == '_blank') continue;
      _els[_i2].onclick = function() {window.onbeforeunload = function(){};}
      }
      }

      window.onbeforeunload = function() {
      setTimeout(function() {
      window.onbeforeunload = function() {};
      setTimeout(function() {
      document.location.href = __redirect_to;
      }, 500);
      },5);
      return 'WAIT BEFORE YOU GO! CLICK THE *CANCEL* BUTTON RIGHT NOW! PAGE. GET YOUR FREE DISCOUNT COUPON.';
      }
      }, 500);
      })();
      </script>
  • That script will popup if theres a domain included in the links is that the case?
    • [1] reply
    • No, no domain included.

      only relative links

Next Topics on Trending Feed