Tuesday, June 4, 2024
 Popular · Latest · Hot · Upcoming
102
rated 0 times [  105] [ 3]  / answers: 1 / hits: 21116  / 11 Years ago, tue, february 11, 2014, 12:00:00

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?


More From » html

 Answers
4

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>




[#72588] Monday, February 10, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
claudiofredye

Total Points: 583
Total Questions: 101
Total Answers: 115

Location: Sao Tome and Principe
Member since Wed, Dec 29, 2021
2 Years ago
;