I would like to track the download time of a specific file. So I am looking for are there any:
$(window).downloadComplete(function()
{....
});
If not, is it possible to track the download used time for a file through PHP/JavaScript?
I would like to track the download time of a specific file. So I am looking for are there any:
$(window).downloadComplete(function()
{....
});
If not, is it possible to track the download used time for a file through PHP/JavaScript?
You can use the onload
event to capture when something has been loaded (for example an image), or you could use an AJAX request with a success callback:
$.get('somefile.txt', function () {
// executes when somefile.txt has been retrieved
});
Here is an onload example for an image, this doesn't even use jQuery:
var myImage = new Image();
myImage.onload = function () {
// executes when the image is loaded
};
myImage.src = 'myimage.png';
If you are interested in the load time of the current page, you have two events you can use.
document ready (the HTML is all downloaded)
$(function () {
// the DOM is ready (so the HTML is downloaded, but images etc may not be)
});
onload (the document and all resources and images are downloaded)
window.onload = function () {
// the DOM and all images etc are downloaded
};
You mean on page loaded totally?
It's extractly:
$
(document).onload(){
//do something
}