Not sure it is what you are looking for, this will redirect user if he choices to stay on page:
DEMO
var a,b;
window.onbeforeunload = function (e) {
if (b) return;
a = setTimeout(function () {
b = true;
window.location.href = "http://google.com";
}, 500);
return "Before you leave, please take a look at this limited time offer.";
}
window.onunload = function () {
clearTimeout(a);
}