Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable all hyperlinks in any website

Is there a way to disable all hyperlinks in any website using javascript?

The reason I want to do this is for text-selection. Many websites are putting whole blocks of text inside tags, making it difficult to select text.

I use chromium and firefox on kubuntu 13.10.

like image 732
qed Avatar asked Apr 21 '14 08:04

qed


2 Answers

To disable all links use

$('a').bind("click.myDisable", function() { 
   return false; 
});

and to enable it use

$('a').unbind("click.myDisable");
like image 139
Animesh Avatar answered Sep 20 '22 21:09

Animesh


Okay completely different answer to my deleted answer using what Rob G said.

for (var x=document.links.length-1;x>=0;x--) {
document.links[x].removeAttribute("href")
}
like image 33
Greg Hornby Avatar answered Sep 17 '22 21:09

Greg Hornby