There are a few ways to call a Javascript function from a link. If the function does not return a value, then you may use:
<a href="javascript:Function();">Click me</a>
However, if the function returns a value, then using the above link will cause the page to display the return value.
Another popular implementation uses “#” as the href attribute value, and puts the function call in the onclick attribute:
<a href="#" onclick="javascript:Function();">Click me</a>
This will not cause the page to display the return value, but it will have the affect of returning to the top of the page.
The solution is to use the void operator. The void operator discards the value of its operand and returns undefined. You may then put the call to a Javascript function in the href attribute and not worry about having the page to display the return value:
<a href="javascript:void Function();">Click me</a>
I’m curious to find out what blog platform you happen to be working with? I’m having some small security issues with my latest blog and I’d like to find something more safeguarded. Do you have any solutions?
Comment by Cathern Brazle — April 12, 2011 @ 3:31 pm
I would add that they also have the electoral system in their pockets. We can only elect whom they allow us to vote for.luxury brands
Comment by Alesia Wackenhut — January 5, 2012 @ 12:07 am