Click the hyperlink to call the implementation of javascript Functions

Source: Internet
Author: User

Click the hyperlink to call the javascript function. Generally, <a href = "javascript: function ();"> however, this disadvantage is that after you click the link, the GIF animation on the page will remain static.

Compile the following code:

 

 <a href = "javascript: Foo ();" _ fcksavedurl = "javascript: Foo (); "> link to make GIF animation static </a> <br/> <center> for more tutorials, visit: <a href = http://www.bkjia.com/target = _ blank _ fcksavedurl = "http://www.bkjia.com/target = _ blank"> http://www.bkjia.com/</a> </center>

Tip: the code can be modified before running!

Solution:
<A onclick = "javascript: Foo ();"> link </a>
In this case, the animation display is not affected, but the style of the mouse and hyperlink does not change after the mouse is moved up. Although you can use the style sheet to change the mouse and hyperlink style, it is complicated after all, besides, this is not a good idea.
Check the following code:
<A onclick = "javascript: Foo ();" href = "#"> link </a>
We can find that although clicking the link does not affect the animation display, the page is always rolled to the top, and this effect is not what we want.

Final Solution:
<A onclick = "javascript: Foo (); return false;" href = "#"> GIF links are not affected </a>
After the link is clicked, onclick is triggered first, and then the value corresponding to the href attribute is executed. In onclick, return false is added. If the execution is interrupted, the page will not jump to the top of the page.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.