1
Based on an example by Sergio - How to prevent a click on a link/anchor or tied event element
Example of my own making
var ancora = document.getElementsByClassName('baixar');
for (var i in ancora) {
document.captureEvents(Event.MOUSEUP | Event.MOUSEDOWN | Event.CLICK | Event.DBLCLICK)
ancora[i].onclick = colorir;
ancora[i].ondblclick = colorir;
ancora[i].onmouseup = colorir;
ancora[i].onmousedown = colorir;
}
function colorir() {
var bloqueado = true;
if (bloqueado) return false;
}
<div id='lista'>
<p><a href="https://sites.google.com/site/mplayerplugin/repositorio/skate.webm">Skate</a></p>
<p><a href="https://sites.google.com/site/mplayerplugin/repositorio/animais_cantando.webm" class="baixar">Animais cantando</a></p>
<p><a href="https://sites.google.com/site/mplayerplugin/repositorio/equipment_these_days.webm" class="baixar">Equipment these days</a></p>
<p><a href="https://sites.google.com/site/mplayerplugin/repositorio/peck_pocketed.webm" class="baixar">Peck Pocketed</a></p>
<p><a href="https://sites.google.com/site/mplayerplugin/repositorio/procurando_dory.webm">Procurando Dory 2</a></p>
</div>
Said in the title, and seen in the example in snippet would like to block the onclick
on all elements of the div
list.
Citation of Sergio
A last option suggested here is to block this element with another element. Using the z-index it is possible to override another element, in this case transparent to without the user noticing (and without spoiling the layout) superimpose this element that wants to "protect" from clicks, or other interaction. Note that this option prevents, for example, selecting text and other events in elements that may be visible, making it inaccessible to the user.
And it would be like Sergio did in this instance. Yet I wanted something simpler, a readable semantics, didactic.
Do you want to block the link with another element so you cannot select or only prevent mouse events? in the latter case
pinter events
would be the best...– Sergio