I want to run a JS function after a link is clicked. I modified the onclick of my links so a setTimeout is setup, allowing the location to change to wherever the link specified it. The problem is, I want to minimize this setTimeout so that the user doesn't have to wait longer than necessary before the function is called. I have a loop in the setTimeout, looping while the document.readyState != 'complete', but the problem with this is document.readyState == 'complete' if the browser is still looking up the hostname, or whatnot. In other words, that doesn't work until the browser has begun loading the other page. Is there something else I can do to loop while the browser is waiting to locate the other webpage/look up its IP? Currently I just have setTimeout to 1.5 secs and then assume the page has begun loading, but this is not a good assumption.

I appreciate any help anyone can offer.

Chad Waldman

P.S. I DO NOT, for reasons I won't go into, want to replace the .href with some javascript.