<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>浏览器右键提示</title>
</head>
<body>
<div class="container">
<h1>浏览器右键提示</h1>
<p>我做了个右键提示,无论您是手机端还是电脑端还是MacOS系统,都能显示提示浏览器提示</p>
<p>所以...这个是我兄弟要做的,想要源码的可以<a href="#" style="color: rgb(255, 182, 193);">点击我</a>获取源码(作者比较喜欢粉色所以就用粉色啦)</p>
<br>
<p>使用方法:</p>
<p>电脑端:右键点击页面会弹出浏览器提示</p>
<p>手机端:长按文字会弹出浏览器提示</p>
<br>
<h3>点击浏览器提示的确认按钮即可关闭</h3>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
let touchTimer = null;
document.addEventListener('contextmenu', function(event) {
event.preventDefault();
showBrowserNotification();
});
document.addEventListener('touchstart', function(event) {
touchTimer = setTimeout(function() {
showBrowserNotification();
}, 3000);
});
document.addEventListener('touchend', function(event) {
if (touchTimer !== null) {
clearTimeout(touchTimer);
touchTimer = null;
}
});
function showBrowserNotification() {
alert('喵~右键功能正在维护呢~~~');
}
});
</script>
</body>
</html>
index.html