If the user clicks a link, I want to call a Javascript function if JS is enabled, or go to a URL if it's disabled. How to solve this? I've tried
<a href="/url?img=2" onclick="changeImage(2); return false;">
but it doesn't seem to work.
If the user clicks a link, I want to call a Javascript function if JS is enabled, or go to a URL if it's disabled. How to solve this? I've tried
<a href="/url?img=2" onclick="changeImage(2); return false;">
but it doesn't seem to work.
Try returning false
from your JavaScript function. This causes the browser to halt and not follow the link after your function is finished.
I'm assuming that when you click the link now, you are just taken to the url and the JavaScript does not seem to work. Is that correct?