call CGI inside onclick event of a link

Discussion in 'Javascript' started by Miroslav Stampar [MCSD.NET / Security+], Jun 2, 2007.

  1. 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 :)
     
    Miroslav Stampar [MCSD.NET / Security+], Jun 2, 2007
    #1
    1. Advertising

  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/
     
    Miroslav Stampar [MCSD.NET / Security+], Jun 2, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard Thoms
    Replies:
    6
    Views:
    4,962
    Richard Thoms
    Dec 2, 2005
  2. Matt
    Replies:
    5
    Views:
    202
    Michael Winter
    Feb 12, 2004
  3. Jerry Sievers
    Replies:
    4
    Views:
    175
    Jerry Sievers
    Jul 31, 2005
  4. Jake Barnes
    Replies:
    1
    Views:
    177
  5. Miroslav Stampar [MCSD.NET / Security+]

    Link OnClick event

    Miroslav Stampar [MCSD.NET / Security+], Jun 2, 2007, in forum: Javascript
    Replies:
    1
    Views:
    125
    Peter Michaux
    Jun 5, 2007
Loading...

Share This Page