Wednesday, April 02, 2008

load a track link when window.onunload

When close this window or leave this page will get request below, this trick may be cause bad user experience, and Opera will ignore it:
***.***.***.*** - - [02/Apr/2008:23:10:18 +0800] "GET /track.html?1207149018624 HTTP/1.1" 301 253


<script type="text/javascript">
window.onunload = function(){
var img = new Image(1,1), i = 0;
img.src = "http://www.test.com/track.html?" + (new Date()).getTime();
while(i < 1000000) i++ ; // for img src load
};
</script>


window.onbeforeunload will pop out a confirm dialog, so can't using onbeforeunload.

No comments :