Use the following javascript code and add into your html file
<script>
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
return false;
}
function mousehandler(e){
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
//disable control+click
function disableCtrlKeyClick(e)
{
var key;
var isCtrl;
if(window.event)
{
key = window.event.keyCode; //IE
if(window.event.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
else
{
key = e.which; //firefox
if(e.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
//if ctrl is pressed dont open the link in new tab
if(isCtrl)
{
e.preventDefault();
return false;
}
return true;
}
</script>
In HTML file use following code
<a herf="http://google.com" onclick="disableCtrlKeyClick(event)" >google.com </a>
The post How to disable right and control click on link appeared first on DIG into CMS.
