目錄
如何阻止使用者截圖?
範例
結論
首頁 web前端 css教學 是否可以阻止使用者對網頁進行截圖?

是否可以阻止使用者對網頁進行截圖?

Sep 10, 2023 am 10:17 AM

是否可以阻止使用者對網頁進行截圖?

在瀏覽網路時,使用者可能會發現需要擷取某些內容以便向某人展示或展示,但有時網頁上可能存在開發人員可能不希望使用者對其進行螢幕截圖的敏感資訊。

使用者可以按下功能鍵以及Windows鍵和空白鍵來進行螢幕截圖。在 MacOS 中,我們必須使用指令、shift 和 3 來截取螢幕截圖。

在本文中,我們將了解如何阻止使用者對網頁進行螢幕截圖。

如何阻止使用者截圖?

無法停用截圖命令,因為這些是內建功能並由作業系統控制。我們可以使用 HTML、CSS 和 JavaScript,但仍然無法阻止使用者截圖。阻止用戶截圖是一項艱鉅的任務,因為用戶可以複製貼上網站內容,也可以使用一些第三方軟體來做到這一點。

但是,我們可以透過一些方法來在一定程度上避免使用者對網頁進行截圖。

範例

在下面的範例中,我們插入了一些文本,然後將其包含在 div 中,然後包含在 CSS 部分中。之後,我們使用媒體查詢並將顯示設為無。這樣,內容將對用戶可見,但用戶將無法列印螢幕。

<!DOCTYPE html>
<html lang="en">
<head>
   <title>Example of disabling the printing </title>
   <style>
      @media print {
         html,
         body {
            display: none;
         }
      }
   </style>
</head>
<body>
   <div>
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
      the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type
      and scrambled it to make a type specimen book. It has survived not only five centuries, but also the 
      leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with
      the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
      publishing software like Aldus PageMaker including versions of Lorem Ipsum.
   </div>
</body>
</html>
登入後複製

範例

在下一個範例中,我們將透過在螢幕上顯示一則訊息來警告使用者不要複製或截圖網頁內容。

<!DOCTYPE html>
<html lang="en">
<head>
   <title>Example of disabling the printing </title>
   <style>
      html {
         user-select: none;
      }
   </style>
</head>
<body>
   <div>
      Lorem Ipsum is simply dummy text of the printing and typesetting industry.
      Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
      when an unknown printer took a galley of type and scrambled it to make a type specimen book.
      It has survived not only five centuries, but also the leap into electronic typesetting,
      remaining essentially unchanged. It was popularised in the 1960s with the release of
      Letraset sheets containing Lorem Ipsum passages, and more recently with desktop 
      publishing software like Aldus PageMaker including versions of Lorem Ipsum.
   </div>
</body>
</html>
登入後複製

在上面的程式碼中,我們使用了與上一個範例中使用的相同段落,這次在 CSS 部分中,我們使用了 user-select 屬性並將其值設為 none。現在,用戶將能夠看到螢幕上的內容,但無法選擇它。輸出如下

範例

在下一個範例中,我們將透過在螢幕上顯示一則訊息來警告使用者不要複製或截圖網頁內容。

<!DOCTYPE html>
<html lang="en">
<head>
   <title>Example of printing a warning message to the user </title>
   <script>
      alert("Please!! do not try to take any kinds of screenshot of the content");
   </script>
</head>
<body>
   <div>
      Lorem Ipsum is simply dummy text of the printing and typesetting industry.
      Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
      when an unknown printer took a galley of type and scrambled it to make a type 
      specimen book. It has survived not only five centuries, but also the leap into 
      electronic typesetting, remaining essentially unchanged. It was popularised in 
      the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, 
      and more recently with desktop publishing software like Aldus PageMaker 
      including versions of Lorem Ipsum.
   </div>
</body>
</html>
登入後複製

在上面的程式碼中,我們再次使用了相同的段落,並使用了 JavaScript 中的一行程式碼,如果使用者嘗試截取網頁螢幕截圖,這將會向使用者發出警告。

結論

不可能完全阻止用戶進行任何類型的螢幕截圖或複製然後將您的內容貼到其他第三方網站上。列印畫面是 Windows 和 MacOS 等每個作業系統都提供的內建功能,而這些功能無法停用,因為它們由作業系統控制。我們只能在一定程度上阻止用戶複製內容,而不能超過此限度。

以上是是否可以阻止使用者對網頁進行截圖?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

<🎜>:泡泡膠模擬器無窮大 - 如何獲取和使用皇家鑰匙
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
北端:融合系統,解釋
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆樹的耳語 - 如何解鎖抓鉤
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Java教學
1664
14
CakePHP 教程
1423
52
Laravel 教程
1321
25
PHP教程
1269
29
C# 教程
1249
24
使Sass更快的概念證明 使Sass更快的概念證明 Apr 16, 2025 am 10:38 AM

在一個新項目開始時,Sass彙編發生在眼睛的眨眼中。感覺很棒,尤其是當它與browsersync配對時,它重新加載

靜態表單提供商的比較 靜態表單提供商的比較 Apr 16, 2025 am 11:20 AM

讓我們嘗試在這裡造成一個術語:“靜態表單提供商”。你帶上html

每周平台新聞:HTML加載屬性,主要的ARIA規格以及從iframe轉移到Shadow dom 每周平台新聞:HTML加載屬性,主要的ARIA規格以及從iframe轉移到Shadow dom Apr 17, 2025 am 10:55 AM

在本週的平台新聞綜述中,Chrome引入了一個用於加載的新屬性,Web開發人員的可訪問性規範以及BBC Move

與部分元素的交易 與部分元素的交易 Apr 12, 2025 am 11:39 AM

同一天發表了兩篇文章:

帶有HTML對話框元素的一些動手 帶有HTML對話框元素的一些動手 Apr 16, 2025 am 11:33 AM

這是我第一次查看HTML元素。我已經意識到了一段時間,但是尚未將其旋轉。它很酷,

多腳步滑塊:一般案例 多腳步滑塊:一般案例 Apr 12, 2025 am 10:52 AM

這個兩部分系列的第一部分詳細介紹了我們如何獲得兩次跑步的滑塊。現在,我們&#039;

我們如何標記Google字體並創建Goofonts.com 我們如何標記Google字體並創建Goofonts.com Apr 12, 2025 pm 12:02 PM

Goofonts是由開發人員和設計師丈夫簽名的附帶項目,它們都是版式的忠實擁護者。我們一直在標記Google

它全部都在頭上:管理帶有React頭盔的React Power Site的文檔頭 它全部都在頭上:管理帶有React頭盔的React Power Site的文檔頭 Apr 15, 2025 am 11:01 AM

該文檔負責人可能不是網站上最迷人的部分,但是其中所處的內容對於您的網站的成功也一樣重要

See all articles