Miroslav Stampar [MCSD.NET / Security+] said the following on 6/2/2007
10:40 AM:
Does anybody have an idea how to call CGI on a onclick event when link
is clicked. This is a sample that works in some situations but
sometimes new page loading is to fast.
<a href="http://www.google.com" onclick="new Image().src=\'http://
www.example.com/process.cgi?p=1\'">
Your question isn't so much of how to call the CGI, you are calling it.
Your question is how to make sure the call went through and the server
got the call. The only way to do that is to have the server tell you it
got the call and then allow navigation to continue. Search the archives
for "image onload problems" and you can read some of the problems
associated with trying to ensure that the Image resource got returned.
onclick="return runTheCGI(this.href)"
function runTheCGI(URL){
var temp = new Image();
temp.src = "http://www.example.com/process.cgi?p=1";
temp.onload = function(){document.location.href=URL};
return false;
}
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -
http://jibbering.com/faq/index.html
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/