Reputation: 4564
I have a href tag that goes like this :
href="download.php?file={$sp->attachment_1}&flag=ds&r_id={$userid}&scpl_id={$sp->sp_id};"
that works and downloads the intended file. the issue is I want it to also call a javascript function. so when someone click it downloads the pdf file AND calls a javascript function but I can't get it to work, I tried using onClick but then it won't download if I put the link there.any suggestions would be greatly appreciated thank you
Upvotes: 1
Views: 4031
Reputation: 1319
Did you tried returning True
from the function,
onclick="return doAction()"
script,
function doAction(){
// do something
return true
}
Upvotes: 0
Reputation: 9027
If you're using jQuery you can just do this:
$("#IDOFYOURLINK").click(function() {
yourJavascriptFunction();
});
Upvotes: 0
Reputation: 2845
As soon as it redirects to the other page (download.php) you cannot run any javascript on this page.
If you want to do the javascript before, it is possible to say:
onclick='do_someting(); window.location="download.php?file=..."'
Upvotes: 1