I need to disable right-click on a hyperlink which is in a span. I need to disable only one link from the whole page. Any suggestions?
Disable right click menu in html page using jquery. JavaScript Code: $(document). bind("contextmenu",function(e){ return false; });
Disable a link # It is still possible to disable a link by following 3 steps: remove the href attribute so that it can no longer receive the focus. add a role="link" so that it is always considered a link by screen readers. add an attribute aria-disabled="true" so that it is indicated as being disabled.
If you dont want to show the context menu on hyperlink, you can do so without doing anything to other part or even span where it exists. I tested in IE, Firefox and it works.
<a href="#" oncontextmenu="return false;"> Link </a>
This should work:
oncontextmenu=”return false;”
Place it on any element you want to disable right click for.
Be aware that this causes bad user experience and users can disable it very easily.
Disclaimer: not tested.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With