views:

40

answers:

1

I need to activate cpa lead when the button is press.

code:

<script type="text/javascript" src="http://www.cpalead.com/mygateway.php?pub=52514&amp;amp;gateid=NjE1Njk%3D"&gt;&lt;/script&gt;.

And the button is just <input type="button" />

So I need to activate the <script> after the button is clicked. Help please?

+1  A: 

You will have this button as:

<input type="button" id="activator" />

and then your JS Code

  var loaded = false;
  $("#activator").click(function(){
     if (!loaded) {
        $.getScript("http://www.cpalead.com/mygateway.php?pub=52514&amp;amp;gateid=NjE1Njk%3D",  function(){ loaded = true; });
     } else {
        alert("script already loaded");
     }
     return false;
  });

Not tested, but as documented in the JQuery documentation, it should work...

References:

Garis Suero
It works, well kinda. After the click it goes to a new page.
omnix
check it now... forgot about the return false to prevent default...
Garis Suero
And remember, if it works for you you can accept that answers as the `answer`
Garis Suero
Nope it still goes to a new page.
omnix