Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to make entire web page links non clickable [duplicate]

Possible Duplicate:
Override default behaviour for link ('a') objects in Javascript

What is the best way for making entire page links in home page read only (non clickable like href=# or href="javascript:void()" based on a user action.

I wanted to use only Javascript and CSS to achieve this.

like image 561
Codemator Avatar asked Dec 01 '22 21:12

Codemator


2 Answers

Only css

a {
    pointer-events: none;
    cursor: default;
}
like image 192
Caelea Avatar answered Dec 10 '22 12:12

Caelea


try

with jquery

$("a").click(function() { return false; });

vanilla js

        var elements = document.getElementsByTagName("a");
        for (var i = 0; i < elements.length; i++) {
            elements[i].onclick = function () { return false; }
        }
like image 43
Veli Gebrev Avatar answered Dec 10 '22 12:12

Veli Gebrev