This article describes the method of JS to block right-click copying and ctrl+c copying. Share it for your reference, as follows:
Some websites always block your right mouse button or use shortcut keys to copy it. In fact, it is just a piece of js code. The solution is to save the web page directly and delete the following js code, and then you can use the right-click menu normally.
Of course, you can also solve the problem by setting the browser's security level to the highest level.
Method 1: Add it directly into the body tag:
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head><body oncontextmenu="return false" onselectstart="return false" oncopy="return false"><ul> <li><a href="###">Who reads you to recite, the water falls you to recit</a></li> <li><a href="###">Who reads you to recit, the water falls you to recit</a></li> <li><a href="###">Who reads you to recit, the water falls you to recit</a></li> <li><a href="###">Who reads you to recit, the water falls you to recit</a></li> <li><a href="###">Whoever asks you to recite, the water falls and the fragrance floats</a></li> <li><a href="###">Whoever asks you to recite, the water falls and the fragrance floats</a></li> <li><a href="###">Whoever asks you to recite, the fragrance floats</a></li></ul></body></html>
Method 2: Write a JS script to control:
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head><body><ul> <li><a href="###">Who asked you to recite, the water fell and the fragrance floated</a></li> <li><a href="###">Who asked you to recite, the water fell and the fragrance floated</a></li> <li><a href="###">Who asked you to recite, the water fell and the fragrance floated</a></li> <li><a href="###">Who asked you to recite, the water fell and the fragrance floated</a></li> <li><a href="###">Who asked you to recite, the water fell and the fragrance floated</a></li> <li><a href="###">Who asked you to recite, the water fell and the fragrance floated</a></li> <li><a href="###">Whoever asks you to recite, the water falls and the fragrance floats</a></li> <li><a href="###">Whoever asks you to recite, the water falls and the fragrance floats</a></li></ul><script>document.oncontextmenu = function(){ return false;}document.onkeydown = function(){ if (event.ctrlKey && window.event.keyCode==67){ return false; }}document.body.oncopy = function (){ return false;}//It is not recommended that you not even select text document.onselectstart = function(){ //return false;}</script></body></html>The renderings are as follows:
For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript Traversal Algorithm and Skills", "Summary of JavaScript Switching Special Effects and Skills", "Summary of JavaScript Search Algorithm Skills", "Summary of JavaScript Animation Special Effects and Skills", "Summary of JavaScript Errors and Debugging Skills", "Summary of JavaScript Data Structures and Algorithm Skills" and "Summary of JavaScript Mathematical Operation Usage"
I hope this article will be helpful to everyone's JavaScript programming.