In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you the WordPress article on how to achieve anti-copy code, I hope you will learn a lot after reading this article, let's discuss it together!
Method 1:
Open the current topic header template header.php to find: add the following code to the end:
/ / disable right-click _ document.oncontextmenu = function () {return false}; / / prohibit drag and drop of pictures _ document.ondragstart = function () {return false}; / / disable selection of text _ document.onselectstart = function () {if (event.srcElement.type! = "text" & & event.srcElement.type! = "textarea" & & event.srcElement.type! = "password") return false;else return true;} If (window.sidebar) {_ document.onmousedown = function (e) {var obj = e.target if (obj.tagName.toUpperCase ()) = = "INPUT" | | obj.tagName.toUpperCase () = = "TEXTAREA" | | obj.tagName.toUpperCase () = = "PASSWORD") return true;else return false;}}; / / prohibit frame tags from referencing if (parent.frames.length > 0) top.location.replace_ (document.location)
Method 2:
The above method is a bit messy when viewing the source code. You can create a new file named copyright.js in the current theme directory and add the following code:
/ / disable right-click _ document.oncontextmenu = function () {return false}; / / prohibit drag and drop of pictures _ document.ondragstart = function () {return false}; / / disable selection of text _ document.onselectstart = function () {if (event.srcElement.type! = "text" & & event.srcElement.type! = "textarea" & & event.srcElement.type! = "password") return false;else return true;} If (window.sidebar) {_ document.onmousedown = function (e) {var obj = e.target if (obj.tagName.toUpperCase ()) = = "INPUT" | | obj.tagName.toUpperCase () = = "TEXTAREA" | | obj.tagName.toUpperCase () = = "PASSWORD") return true;else return false;}}; / / prohibit frame tags from referencing if (parent.frames.length > 0) top.location.replace_ (document.location)
Then add the following code to the end of the current theme function template functions.php:
Function copyrightpro_scripts () {wp_enqueue_script ('copyright', get_template_directory_uri (). '/ copyright.js', array (), false);} if (! Current_user_can ('level_10')) {add_action (' wp_enqueue_scripts', 'copyrightpro_scripts');}
A judgment is added to the code, and the administrator logs in for a while, and the anti-copy code is invalid.
Of course, the above method is only a hoax, after the browser disables JavaScript, it will lose its effect.
After reading this article, I believe you have a certain understanding of the WordPress article on how to achieve copy-proof code, want to know more about it, welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.