Not sure why you'd want to do this but it can be done by moving the href
to a data-href
attribute, then remove the href
and add a click handler. The onclick will read the data-href
and redirect.
Demo
var links = document.getElementsByTagName("a");
for(var i=0; i<links.length; i++){
links[i].setAttribute("data-href", links[i].getAttribute("href"));
links[i].removeAttribute("href");
links[i].onclick = function(){
window.location = this.getAttribute("data-href");
};
}
The right click menu shows:
