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

Solution to the problem of mysql service starting but not connecting

The mysql service is started, but the connection ...

CSS3+Bezier curve to achieve scalable input search box effect

Without further ado, here are the renderings. The...

Analyze the difference between ES5 and ES6 apply

Table of contents Overview Function signature Opt...

Detailed explanation of explain type in MySQL

Introduction: In many cases, many people think th...

Solution to the problem that the docker container cannot be stopped

The solution is as follows: 1. Force delete conta...

HTML table tag tutorial (20): row background color attribute BGCOLOR

The BGCOLOR attribute can be used to set the back...

Storage engine and log description based on MySQL (comprehensive explanation)

1.1 Introduction to storage engines 1.1.1 File sy...

MySQL sorting feature details

Table of contents 1. Problem scenario 2. Cause An...

In-depth explanation of currying of JS functions

Table of contents 1. Supplementary knowledge poin...

Use vue3 to implement a human-cat communication applet

Table of contents Preface Initialize the project ...

Analysis of the cause of docker error Exited (1) 4 minutes ago

Docker error 1. Check the cause docker logs nexus...

A brief talk about cloning JavaScript

Table of contents 1. Shallow cloning 2. Deep clon...

Solution to forgetting the MYSQL database password under MAC

Quick solution for forgetting MYSQL database pass...

Implementation code for adding slash to Vue element header

<template> <div class="app-containe...