PDA

View Full Version : Wait don't leave dropin...?



benniaustin
02-26-2007, 10:27 PM
Hey all, I need a bit of help.

The client is requesting a wait don't leave drop in, much like a wait don't leave popup that presents the user with a deal using the onUnload event in javascript. At first I thought this was impossible, but now it seems almost possible.

I've created the dhtml drop-in using javascript function on on the onbeforeUnload event attached to the body, then, used one of these guys for on the unload: document.execCommand('Stop');. I'm aware that this only will work in ie, and the client is fine with that. (90%+ users are using IE on this site).

The problem here is that I need to capture the url they were about to go to, so I can add that to a link on the drop in. As it is right now, this code makes it impossible for IE users to leave the site. The drop in will have a special offer, with a "buy now" link and a "leave the page" link. I need that "leave the page" link to go to whatever link they were going to go to.

Is there any way to capture this information? Just getting the info from links on the page, should not be to difficult, but all of the links on the page will have the dropin suppressed anyway, that's now what I need. I need to capture the url if it is typed into the address bar, or accessed from a bookmarked link.

benniaustin
02-27-2007, 03:21 PM
Bump, Bump.

Sorry, I need this.... anyone?

Blake
02-27-2007, 04:12 PM
I'm pretty sure that's impossible.

jscheuer1
02-27-2007, 04:30 PM
I'm not sure how you got that much working. There may be no solution but, if I could see your actual page, I might be able to figure it out.

benniaustin
02-27-2007, 05:52 PM
Here's what I've come up with so far. I just need a way to capture the page they were about to go to. At first, I thought what I've done thus far was impossible, but it's not. So, I'm not giving up on this just yet. By the way, I got rid of the drop-in JS, and replaced it with a simple showDiv function to clean up the code, since that's not what I'm having a problem with.


<html>
<head>
<style>#dropInDiv { border:1px solid #000; background:#ddd; position:absolute; top:200px; left:200px; display:none;}</style>
<script>
function showDropIn(divName){
document.getElementById(divName).style.display='block';
}
function leaveSite() {
//this is what I'm missing!
}
</script>
</head>
<body onbeforeunload="showDropIn('dropInDiv')" onunload="document.execCommand('Stop');">

<div id="dropInDiv">
<p>wait dont leave!</p>
<p>take an additional 10% off now.</p>
<ul>
<li><a href="fakelink.htm">Give me 10%off</a></li>
<li><a href="javascript:leaveSite();">Just let me leave already!!!</a></li>
</ul>
</div>

<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris dolor. Nullam blandit tristique dui. Proin venenatis mattis arcu. Suspendisse potenti. Integer placerat nisl sit amet erat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Quisque fringilla lorem eget mauris. Nunc fermentum pellentesque leo. Proin orci orci, sollicitudin vel, iaculis et, facilisis eu, justo. Nunc libero quam, ornare a, vestibulum id, rutrum eget, dolor.</p>
</body>
</html>

Thanks for having a look, Much appreciated.

pcbrainbuster
02-27-2007, 05:55 PM
I am very sorry but it is pretty much seeming impossible -
well there is only one solution and its not that good anyway but if you do want to know jus ask :)

benniaustin
02-27-2007, 06:00 PM
Please by all means.