How to call javascript function instead of href in html
I have some mockup in HTML
<a href="javascript:ShowOld(2367,146986,2)"><img title="next page" alt="next page" src="/themes/me/img/arrn.png"></a>
When i sent the request i got the response from the server
With this mockup i have as a response to a request from ajax that sends my code to the server
Well, everything is fine but when I click on the link the browser wants to open the function as link; meaning after click I see the address bar as
javascript:ShowOld(2367,146986,2)
means browser thing that's url if I want to do this in firebug that's work. Now i want to do that then when anyone clicks the link then the browser tries to call the function already loaded in the dom instead of trying to open them in browser.
Best Answer
That syntax should work ok, but you can try this alternative.
<a href="javascript:void(0);" onclick="ShowOld(2367,146986,2);">
or
<a href="javascript:ShowOld(2367, 146986, 2);">
UPDATED ANSWER FOR STRING VALUES
If you are passing strings, use single quotes for your function's parameters
<a href="javascript:ShowOld('foo', 146986, 'bar');">