Get the App
SLTechnology News&Howtos  ›  Servers  › 

JS realizes copying web page content and automatically adding copyright content code and original text link.

Shulou Source: shulou.com Published: 2022-06-02 19:33:04 10月02日 Update

Var Sys = {}; var ua = navigator.userAgent.toLowerCase (); if (window.ActiveXObject) {document.body.oncopy = function () {event.returnValue = false; var t=document.selection.createRange (). Text; var s = "original link:" + location.href; clipboardData.setData ('Text',t+'\ r\ nlinks);} } else {function addLink () {var body_element = document.getElementsByTagName ('body') [0]; var selection; selection = window.getSelection (); var pagelink = "original link:" + location.href; var copytext = selection + pagelink; var newdiv = document.createElement (' div'); newdiv.style.position='absolute'; newdiv.style.left='-99999px' Body_element.appendChild (newdiv); newdiv [XSS _ clean] = copytext; selection.selectAllChildren (newdiv); window.setTimeout (function () {body_element.removeChild (newdiv);}, 0);} _ document.oncopy = addLink;}

Copy the above code in the html file and paste it in front of the / body code

Gathering network

Tags: Code original text links content files web copyright web pages Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Tech Info Docker NVidia Shulou Information