I have a link as follows:
<a href="www.google.com" onClick="someFunction()">Click me</a>
On clicking the link, it's executing the JavaScript function, but it is not taking me to the href link.
How can I achieve the same?
I think the easiest way to do it is to make your function return true, so that after the function is complete, the anchor tag will behave like it normally does. This way you can also use the target-attribute if you want to use new window:
function myFunction() {
alert("hello");
return true;
}
<a href='http://www.google.com' onclick="myFunction();" target="google">Click me</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With