I need a pure Javascript code to disable all links while loading the page, avoiding to click them and redirecting to other page when its using a Facebox.
Can be something that I place in a <script> tag in the <head>.
Any suggestions?
EDIT:
Ok, I get that in head doesn’t work. But in body ending work properly. That’s why I asked for suggestions. 🙂
Use
document.linksand prevent their default behaviour withpreventDefault().If you wanted a more permanent disabling of the links, use
removeAttribute('href').Place this code somewhere after the closing
bodytag if you don’t want to useDOMContentLoadedor thewindowloadevent.You can’t place it in the
headelement otherwise and have it execute immediately becausedocument.linkswill most certainly be empty.