Click on the hyperlink to call JavaScript functions, most people use:
Copy the code as follows:<a href="javascript:function();">
But this has a disadvantage, that is, after clicking on the link, the GIF animation on the page will be stationary.
Try the following code:
Copy the code as follows:<script type="text/javascript">
<!--
function Foo()
{
//do something
}
//-->
</script>
<img src="logo.gif" />
<a href="javascript:Foo();">Links that make GIF animation still</a>
Solution discussion:
Copy the code as follows: <a onclick="javascript:Foo();">Link</a>
This time, the animation display will not be affected, but after the mouse is moved up, the mouse and hyperlink styles will not change. Although the style sheet can be used to change the mouse and hyperlink styles, it is a bit cumbersome after all, and this idea is not good.
Check the following code again:
Copy the code as follows: <a onclick="javascript:Foo();" href="#">Link</a>
We can find that although clicking on the link does not affect the animation display, the page always scrolls to the top, and this effect is not what we want.
Final solution:
Copy the code as follows: <a onclick="javascript:Foo();return false;" href="#">does not affect the link of the GIF</a>
If you do not consider the issue of GIF images, all the above methods are OK.