[thelist] OnLoad Event to touch file on server

Sam Foster sam at sam-i-am.com
Wed May 4 14:26:25 CDT 2005


Sam Carter wrote:

>
> I'm trying to work with a customer who (I believe) has a proxy that is 
> seriously affecting page load times.   I could timestamp the page load 
> time if I had an OnLoad JavaScript that would just touch an ASP file 
> back on my server.  If anyone has just a JavaScript, please help me out.
>
You could issue a GET request via XmlHttpRequest, like so:

      var xmlDoc = null ;
 
     window.onload = function() {
        if (typeof window.ActiveXObject != 'undefined' ) {
          xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
          xmlDoc.onreadystatechange = process ; // optional?
        }
        else {
          xmlDoc = new XMLHttpRequest();
          xmlDoc.onload = process ;
        }
        xmlDoc.open( "GET", "/your/timestamping/app.asp", true );
        xmlDoc.send( null );
      }
 
      function process() {
        if ( xmlDoc.readyState != 4 ) return ;
       // do something with the response.
      }

in fact, as you don't really need to doing anything with the response, 
you could probably issue a HEAD request, and skip the whole 
onreadystatechange process entirely?

Sam
-i-am



More information about the thelist mailing list