How to prevent hyperlinks from jumping when using a link

How to prevent hyperlinks from jumping when using a link
When using <a href="" onclick="">, some problems occurred, which puzzled me for more than a month. Now I got the following conclusion from netizens, which made me suddenly enlightened and the problem was solved.

The onclick event of the link is executed first, followed by the action under the href attribute (page jump, or javascript pseudo link);
Assume that both href and onclick exist in a link. If you want to prevent the action under the href attribute from being executed, onclick must return a false value.
If the page is too long and has a scroll bar, and you want to perform an action through the onclick event of the link. Its href attribute should be set to javascript:void(0); instead of #, which can prevent unnecessary page jumps;
If a function with a return value is called in the href attribute of a link, the content of the current page will be replaced by the return value of this function;
It makes a difference when holding down the Shift key.
The problem I encountered today is that I cannot access the parentNode in the form of href in IE6.0.
Try not to use the javascript: protocol as the href attribute of A. This will not only cause unnecessary triggering of the window.onbeforeunload event, but will also stop the playing of the gif animation in IE.

<<:  Learn how to use JavaScript's new Element Traversal property to traverse child elements

>>:  onfocus="this.blur()" is hated by blind webmasters

Recommend

Web page image optimization tools and usage tips sharing

As a basic element of a web page, images are one ...

Nginx builds rtmp live server implementation code

1. Create a new rtmp directory in the nginx sourc...

Basic usage tutorial of IPTABLES firewall in LINUX

Preface For production VPS with public IP, only t...

vue-router history mode server-side configuration process record

history route History mode refers to the mode of ...

Experience in solving tomcat memory overflow problem

Some time ago, I submitted a product version to t...

Zabbix configuration DingTalk alarm function implementation code

need Configuring DingTalk alarms in Zabbix is ​​s...

Example of how to build a Harbor public repository with Docker

The previous blog post talked about the Registry ...

Solution to the problem "Table mysql.plugin doesn't exist" when deploying MySQL

Today I deployed the free-installation version of...

How to use Nginx proxy to surf the Internet

I usually use nginx as a reverse proxy for tomcat...

Tutorial on Installing Nginx-RTMP Streaming Server on Ubuntu 14

1. RTMP RTMP streaming protocol is a real-time au...

How to install nginx on win10

Because the company asked me to build a WebServic...

Example of usage of keep-alive component in Vue

Problem description (what is keep-alive) keep-ali...

【HTML element】Detailed explanation of tag text

1. Use basic text elements to mark up content Fir...

Detailed explanation of HTML style tags and related CSS references

HTML style tag style tag - Use this tag when decl...