Now, I understand that it's bad practice to delay a page close, and that there are better ways to handle that kind of stuff, but just for future reference, is there a way to delay the page closing? Something like
window.onunload = unload();
function unload()
{
setTimeout("self.close()", 1000)
}
Thanks!
If you really need (ie. ready to resort to semi-hacks) to delay the page closing without showing a confirmation dialog, etc, you can do something like the following:
function delay(ms) {
var start = +new Date;
while ((+new Date - start) < ms);
}
// start image loading (I assume you need this for tracking?)
delay(150);
The caveats are obvious: it will not always work and you cannot delay for too long. That being said, if you are really interested in this, you can probably get results of over 95% (really depends on the server response time).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With