Home > Web Front-end > Front-end Q&A > How to prohibit saving as html

How to prohibit saving as html

藏色散人
Release: 2023-01-06 11:16:25
Original
3884 people have browsed it

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:

<body  bgcolor="#404040" oncontextmenu = "return false" oncopy = "return false" onselectstart = "return false" >
Copy after login

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;
}
});
Copy after login

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:&#39;&#39;;
width:100%;
height:100%;
position:absolute;
z-index:1000;
background-color:#fff;
opacity:0;
top:0;
left:0;
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template