473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

call CGI inside onclick event of a link

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\'">

Plz help :)

Jun 2 '07 #1
2 5383
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/
Jun 2 '07 #2
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/
Jun 2 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: sindre | last post by:
Hi, Some place I use links to submit forms instead of a submit button. The way I have done this is: <a href="javascript:document.getElementById('<?php print "delete$i"...
17
by: Mike Gratee | last post by:
Is it possible to use JavaScript to cause the browser to click a link on a page and have the browser act exactly like the user had clicked on the link directly? In other words, I need to...
3
by: JoeK | last post by:
Hey all, I am automating a web page from Visual Foxpro. I can control all the textboxes, radio buttons, and command buttons using syntax such as: ...
2
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } ...
4
by: Jerry Sievers | last post by:
JS Programmers, "I'm a server-side coder PHP, Postgres etc... My question; Given the following anchor <a href="http://www.somesite.com/somefile.html">link text</a> Is there a way to code an...
7
by: Bonzo | last post by:
>From within a function, I want to pass a/some parameters to another function, AND all arguments, passed into this function. e.g. function firstFunction(){ //this function may have been...
18
by: Chris Ianson | last post by:
Hi geniuses (or is that genii, or genies) The challenge is as above really. I have a page with an iframe in it, and need to call a JS function in the *parent* page, *from* inside the iframe. ...
11
by: GaryB | last post by:
Hi Guys, I've been battling with this one for hours - I hope that you can help me! My code modifies the <aon a page, from a standard document link into a link with a tailored onclick event. ...
6
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.