Javascript disables the right-click function. JS disables the right-click function.
When you want to save beautiful pictures or wonderful texts on a webpage, you usually select the target and right-click it, select "Save image as" or "copy" in the pop-up menu to achieve our goal. However, many web pages are currently blocked by right-clicking. How can I disable the right-clicking function in JavaScript?
1. JS instructions related to disabling right-click
<script type="text/javascript">document.oncontextmenu=new Function("event.returnValue=false;");document.onselectstart=new Function("event.returnValue=false;");</script>
2. Right-click prohibited Firefox failure
<! DOCTYPE html>
3. Disable Text Selection
<script type="text/javascript">var omitformtags=["input", "textarea", "select"];omitformtagsomitformtags=omitformtags.join("|");function disableselect(e){if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1){return false;}}function reEnable(){return true;}if (typeof document.onselectstart!="undefined"){document.onselectstart=new Function ("return false");}else{document.onmousedown=disableselect;document.onmouseup=reEnable;}</script>
4. shield the ctrl button
document.onkeydown=function(){if(event.ctrlKey)return false;}
The above section describes how to disable right-clicking in JavaScript code. I hope it will be helpful to you. If you have any questions, please leave a message. The editor will reply to you in time, thank you very much for your support for the help House website!