js通过MutationObserver监测实现防删文字水印效果代码
代码语言:html
所属分类:其他
代码描述:js通过MutationObserver监测实现防删文字水印效果代码,水印内容不可删除,如检测到被删除,会重新添加水印
代码标签: js MutationObserver 监测 防删 文字 水印
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum=1.0,minimum=1.0,user-scalable=0" /> </head> <body> <div id="content" style="padding:10px;"> <h2>防删文字水印</h2> 水印内容不可删除,如检测到被删除,会重新添加水印 </div> <script> function add_water_canvas(){ //水印canvas var water_canvas = document.createElement("canvas"); water_canvas.id = "water_canvas"; water_canvas.height = 100; water_canvas.width = 300; water_canvas.style.top = 100 + "px"; water_canvas.style.left = 100 + "px"; water_canvas.style.position = "absolute"; water_canvas.style.transform = "rotate(-45deg)"; //水印内容 var water_text = water_canvas.getContext("2d"); water_text.font = "26px 黑体"; water_text.fillText("水印内容", 30, 50); //canvas容器:水印目标 var canvas_container = document.getElementById("content"); canvas_container.style.height = 280 + "px"; canvas_container.style.width = 500 + "px"; canvas_c.........完整代码请登录后点击上方下载按钮下载查看
网友评论0