4 replies
  • WEB DESIGN
  • |
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
#exit #script
  • Profile picture of the author kevbo22
    Signature

    The best path to prosperity is free market capitalism!

    {{ DiscussionBoard.errors[8819460].message }}
    • Profile picture of the author dlundy1

      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>
      Signature

      Don't Give UP! See how I made mt first $69.73 online :)

      {{ DiscussionBoard.errors[8823393].message }}
  • Profile picture of the author softwarewarden
    Originally Posted by dlundy1 View Post

    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
    That script will popup if theres a domain included in the links is that the case?
    {{ DiscussionBoard.errors[8819643].message }}
    • Profile picture of the author dlundy1
      Originally Posted by softwarewarden View Post

      That script will popup if theres a domain included in the links is that the case?
      No, no domain included.

      only relative links
      Signature

      Don't Give UP! See how I made mt first $69.73 online :)

      {{ DiscussionBoard.errors[8823375].message }}

Trending Topics