How do default actions work in browser - How to prevent them?

I'm currently learning how to handle events, in that case There are some events and actions behave unexpectedly which force me to understand deeply how do browser default actions work. I'd be glad If you came at me with real-life example.

»Javascript @jeph6

» 1 answer  » 14 views   

Add photos

Gadrawin • 1 month ago
According to what I read on Javascript.infoMany events lead to certain actions performed by the browser. By taking a simple example, If you press a mouse button over a text and move it, that text is being selected and certain event occurs. And sometimes unwanted action is performed and you don't want it to go on, What to do, prevent them, how to do it? For instance we have a simple menu inside unordered list element.

<ul id="menu" class="menu">
  <li><a href="/html">HTML</a></li>
  <li><a href="/javascript">JavaScript</a></li>
If its anchor tag, , people have may ways to open the link, Either by right-clicking and open it in new tab or clicking the link, Thus, because search engines normally follow each link inside anchor tag we can prevent that action for some urls by returning false at last line menu.onclick = event => { if ( != 'A') return; let href ='href'); alert( href ); return false; }; »

0  Dislike  •  Reply

Back to top

[SHARE THIS POST]: The post's archived Spread it to others!

Posted under this donnektish »
This community is about sharing contents such as questions and answers discussing about Javascript and TypeScript, ES5, ES6
58 people joined this donnektish

Maintain social distancing, to avoid Covid19