Created
March 30, 2013 06:24
-
-
Save kerryChen95/5275614 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sendLog (urlWithLog) { | |
var img = new Image(), no, caches; | |
if (sendLog.count >= Number.MAX_VALUE) sendLog.count = 0; | |
no = 'no' + sendLog.count++; | |
caches = sendLog.caches; | |
// hold on reference, otherwise image object may be GCed and abort request that has not been send | |
caches[no] = img; | |
// delete reference | |
img.onload = img.onerror = img.onabort = function () { | |
delete caches[no]; | |
}; | |
img.src = urlWithLog; | |
} | |
sendLog.caches = {}; | |
sendLog.count = 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment