<script>
time_taken = 0;
delay = 1000; // delay in ms

function create_iframe() {	
	var ifr = document.createElement("iframe");		
	ifr.onload = (function(ifr) 
	{ 	
		return function() {
			if(time_taken == 0) {
				time_taken = new Date();
			} else {
				time_taken = (new Date() - curr_time - delay);
				document.body.removeChild(ifr);
				console.log(time_taken);
			}				
			
		}})(ifr);
	ifr.src = "payload.html";
	document.body.appendChild(ifr);		
}

document.addEventListener('DOMContentLoaded', function() {	
	create_iframe();
});
</script>
Share