Exit redirect

domainmadness

Supreme Member
Joined
Jun 22, 2011
Messages
1,313
Reaction score
474
Is there any good working exit redirect plugins? Not looking for exit popup, just redirect from current page to another one when mouse is leaving.
 
Gonna bump this once if anybody happens to have any info!
 
Here is the javascript for the mouse leaving the active browser area - just change where it says alert("left window"); to do a Javascript redirect as:

Code:
window.location = "http://www.google.com/"

Code:
<script type="text/javascript">
function addEvent(obj, evt, fn) {
    if (obj.addEventListener) {
        obj.addEventListener(evt, fn, false);
    }
    else if (obj.attachEvent) {
        obj.attachEvent("on" + evt, fn);
    }
}
addEvent(window,"load",function(e) {
    addEvent(document, "mouseout", function(e) {
        e = e ? e : window.event;
        var from = e.relatedTarget || e.toElement;
        if (!from || from.nodeName == "HTML") {
            // stop your drag event here
            // for now we can just use an alert
            alert("left window");
        }
    });
});
</script>
 
Where do you place that code? sounds useful.

Thanks,
 
Last edited:
so in firefox this will automatically redirect to the target page, in chrome the visitor has to hit ok to be redirected.

What do I enter in alert to have a box pop up with a message that redirects to a site? I tried a few things and now there is no pop up or redirect.
Currently I have:
Code:
  alert("message" window.location = "http://www.url.com");
 
so in firefox this will automatically redirect to the target page, in chrome the visitor has to hit ok to be redirected.

What do I enter in alert to have a box pop up with a message that redirects to a site? I tried a few things and now there is no pop up or redirect.
Currently I have:
Code:
  alert("message" window.location = "http://www.url.com");
Confimation window (Ok \ Cancel):
Code:
if (window.confirm('Blah blah blah, click ok to proceed')) {
        window.location.href='http://www.url.com/';
    }

Dialog box ("OK"):

Code:
if (window.alert('You will proceed to our updated site.')) {
        window.location.href='http://www.url.com/';
    }

I haven't tested this, but that's basically what you'll need to get going in the right direction if a copy paste job won't do.
 
this is the first time I have played with java. copy/paste didn't work and the few things I could think to try as variations did not get me there. I will look at it again in the morning. Thanks for the help.
 
this is the first time I have played with java. copy/paste didn't work and the few things I could think to try as variations did not get me there. I will look at it again in the morning. Thanks for the help.

Took a look and tested it. This is the copy\paste job. Put it in the head or body tags.
Code:
<script type="text/javascript">
    window.alert('You will proceed to our updated site.')
    window.location.href='http://www.google.com/';
</script>

Or prompt box:
Code:
<script type="text/javascript">
window.confirm('Blah blah blah, click ok to proceed'
    window.location.href='http://www.google.com/';
</script>
 
You could trigger it with a onclick event by making it into a function pretty easily if you didn't want it on page load.
 
so in firefox this will automatically redirect to the target page, in chrome the visitor has to hit ok to be redirected.

What do I enter in alert to have a box pop up with a message that redirects to a site? I tried a few things and now there is no pop up or redirect.
Currently I have:
Code:
  alert("message" window.location = "http://www.url.com");

No no you just want to replace the entire alert statement with the entire window.location statement - you are combining them.

Look at the functionality and source code at http://www.marketingillusionist.com/test.html
 
Last edited:
Interesting advice, but i would like to know if these tactics will hurt my ranks. Guess not, just asking...
 
@M1ndfluX I do not see why this would hurt you unless a manual review decided they did not like it. I do not know if a robot would trigger this event or not, but I am thinking not.

Anyway, @EveryoneElse

Here is the javascript you should just copy / paste:

Code:
<script type="text/javascript">
function addEvent(obj, evt, fn) {
    if (obj.addEventListener) {
        obj.addEventListener(evt, fn, false);
    }
    else if (obj.attachEvent) {
        obj.attachEvent("on" + evt, fn);
    }
}
addEvent(window,"load",function(e) {
    addEvent(document, "mouseout", function(e) {
        e = e ? e : window.event;
        var from = e.relatedTarget || e.toElement;
        if (!from || from.nodeName == "HTML") {
            // stop your drag event here
            // for now we can just use an alert
            //alert("left window");
		window.location = "http://www.google.com/"
        }
    });
});
</script>
Goodbye - just mouseout the window...

This also has the side-effect of triggering itself if someone right clicks on the page - making it difficult to get to the source code!
 
Last edited:
I think the last line needs a semi-colon:

Code:
window.location = "http://www.google.com/";

I misread the thread some how and didn't see exit redirect. Sorry for the confusion on my end.
 
Unless it's a wp plug in, I'm clueless. Where does one insert this (I need mentally slow-like details) lol
 
Anywhere in between the HTML tags pretty much. I keep mine in above the </head> tag.
 
dont want to resume this old thread, but there is a method to stop firing the redirect when just using the scroll-bar? would be nice to have redirect only when the mouse exit up or down from the page and if he close the page or click the back button
 
dont want to resume this old thread, but there is a method to stop firing the redirect when just using the scroll-bar? would be nice to have redirect only when the mouse exit up or down from the page and if he close the page or click the back button

Go through my threads, I posted a script which hacks the back button. Redirect the user when they go out of your site hitting the back button.
 
yes work great, looking to integrate with this, but without firing on the scroll bar


thanks a lot


may be something to do with CSS?
 
Last edited:
Back
Top