Home>Article>Web Front-end> How to prohibit saving as html

How to prohibit saving as html

藏色散人
藏色散人 Original
2021-06-03 14:46:57 3721browse

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.

How to prohibit saving as html

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:


      

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn