How to prohibit saving as html: 1. Disable saving as via the "$(document).ready(function(){...}" method; 2. Add a "protective layer" to the entire page. Preventing users from operating the real page.
The operating environment of this article: windows7 system, HTML5&&CSS3 version, Dell G3 computer.
HTML How to prohibit copying of text on a page, prohibiting saving of pictures, and prohibiting saving of web pages as
In response to work requirements, it is necessary to control the content of the web page so that it cannot be easily leaked, that is, text cannot be copied, and images on the web page cannot be downloaded. La, you can't save the web page as. There are many examples on the Internet. The method I use is as follows:
<body bgcolor="#404040" oncontextmenu = "return false" oncopy = "return false" onselectstart = "return false" >
It is written like this in js:
$(document).ready(function(){ document.oncontextmenu = function(){ return false; } document.onselectstart = function(){ return false; } document.oncopy = function(){ return false; } });
If it does not take effect, you must first check whether the code has Error, I accidentally deleted the code and did not notice it, causing the above code to not take effect.
Another way is to add a "protective layer" on the entire page so that users cannot operate the real page That’s it.
Method: Find the class attribute of the smallest div to ban the page, and then add the following style. For example, if the class of the div is container, then write like this:
.container{ position:relative; } .container::before{ content:''; width:100%; height:100%; position:absolute; z-index:1000; background-color:#fff; opacity:0; top:0; left:0; }
Pay attention to the z-index If the value is the largest in the entire page, then set the transparency opacity to 0, that is, completely transparent, so that the real data is covered without being noticed.
[Recommended learning: html video tutorial】
The above is the detailed content of How to prohibit saving as html. For more information, please follow other related articles on the PHP Chinese website!