Thornus
Registered Member
- Apr 13, 2017
- 50
- 19
Hi,
Like the title says,I need redirect user after pressing close button in browser.In one thread here I found this code.
It works,but not exactly.It redirects user after his mouse is leaving and not after close button is pressed.
Also I need this script will work
-for mobiles
-redirect specific url to other specific url. So it means each my post will redirect to different url/I use WP
I just need working script and site url + destination url I allways change by myself.
So please guys if someone of you knows how you can send me pm or leave solution here for other members.
Thank you
Like the title says,I need redirect user after pressing close button in browser.In one thread here I found this code.
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>
It works,but not exactly.It redirects user after his mouse is leaving and not after close button is pressed.
Also I need this script will work
-for mobiles
-redirect specific url to other specific url. So it means each my post will redirect to different url/I use WP
I just need working script and site url + destination url I allways change by myself.
So please guys if someone of you knows how you can send me pm or leave solution here for other members.
Thank you