Typecho Copy Popup Notice

Machine-translated (anthropic, claude-haiku-5-5) from the Chinese original. Read the original in 中文

Contents

Foreword

Still preparing for final exams, hehe. I'm squeezing in time to write this post (reviewing is impossible, I'll never review, not in this lifetime).

Main Text

Recently I came across a very nice web popup layer plugin! And the popup layer on the Baota panel is also this one. Simple, convenient, easy to use, and highly extensible! So I started wondering whether I could make a popup that warns the "lawbreakers" who copy content, with a copyright notice!

Step 1

Include the layer JS file. However, I found that none of the major CDN static file acceleration platforms have the latest version, which was quite frustrating. Also, the layer files on the official website don't support HTTPS, so I put them on my own CDN. You can download them from the official website, or directly use the ones I downloaded (served via Alibaba Cloud CDN).

Include the layer resource files in the headre.php file of the template directory, with the following code:

text
<script src="https://cdn.staticfile.org/layer/2.3/layer.js"></script>

If you are using the handsome theme, you can add it to the

Custom output HTML code at the end of body in the developer settings

and add the following to Custom JavaScript:

text
document.body.oncopy = function() {layer.msg('复制成功,若要转载请务必保留原文链接!');};

Done!

The result looks like this:

http://layer.layui.com/

A JavaScript popup (layer) solution that lets you make whatever you imagine.

https://www.ihewro.com/archives/489/

handsome theme —— Looking as young as ever.

Comments