call CGI inside onclick event of a link

  • Thread starter Miroslav Stampar [MCSD.NET / Security+]
  • Start date
M

Miroslav Stampar [MCSD.NET / Security+]

Thank you very much :)

Randy Webb je napisao/la:
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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top