if this is just for your benefit, then the LORI extension for firefox does what you want:
https://addons.mozilla.org/firefox/1743/
otherwise, using a library like prototype it's pretty easy. If that's a problem, then I'd suggest you take the time to figure out what it's doing and pull out the bits you need. Something along the lines of:
add to the beginning of your php script:
PHP Code:
//top of script
session_start();
$_SESSION['start'] = microtime(true);
//rest of script
then as javascript
:
Code:
Event.observe(window,'load',function() {
var url = 'http://www.website.com/timer.php';
var options = {
method: 'get',
onComplete: function(xhr) {
alert(xhr.responseText);
}
};
new Ajax.Request(url,options):
},false);
and timer.php:
PHP Code:
session_start();
if(!isset($_SESSION['start'])) {
die("No start time");
}
$end_time = microtime(true);
$time = $end_time - $_SESSION['start'];
unset($_SESSION['start']);
echo $time;
prototype comes from
http://www.prototypejs.org