wordpress如何禁止页面复制,然后弹出付费复制提醒,对于一些例如百度app里访问,可能有些代码不生效。以下代码仅供参考:
if( /(baiduboxapp|UCBrowser|MQQBrowser|Quark)/i.test(navigator.userAgent.toLowerCase()) ) {
var o = null;
window.ontouchstart = function() {
o = setTimeout((function() {
layer.open({
type: 1,
area: ['360px', ''],
skin: 'layui-layer-dialog',
title: '付费复制',
resize:false,
scrollbar: false,
shadeClose: true,
content: '<div style="text-align:center"><span style="display:inline-block;width:60px;height:60px;border-radius:50%;border:1px solid #999;margin-bottom:20px"><i class="icon icon-copy" style="font-size:36px;line-height:60px"></i></span><div style="font-size:18px;margin-bottom:10px">付费后解锁当前文章复制权限</div><div style="font-size:16px;color:#ff5f33;margin-bottom:20px">本文解锁价格:¥<?php echo $down_price;?></div><a href="javascript:;" style="color:#fff !important;margin-bottom:20px" class="btn erphp-wppay-loader jumppay" data-post="<?php the_ID();?>">立即解锁</a></div>'
});
}), 400)
},
window.ontouchmove = function() {
clearTimeout(o)
},
window.ontouchend = function() {
clearTimeout(o)
}
}else{
jQuery(function($){
var pressTimer;
var longPressTime = 600; // 长按时间,单位:毫秒
$("#article-content").on("touchstart", function(e) {
pressTimer = window.setTimeout(function() {
layer.open({
type: 1,
area: ['360px', ''],
skin: 'layui-layer-dialog',
title: '付费复制',
resize:false,
scrollbar: false,
shadeClose: true,
content: '<div style="text-align:center"><span style="display:inline-block;width:60px;height:60px;border-radius:50%;border:1px solid #999;margin-bottom:20px"><i class="icon icon-copy" style="font-size:36px;line-height:60px"></i></span><div style="font-size:18px;margin-bottom:10px">付费后解锁当前文章复制权限</div><div style="font-size:16px;color:#ff5f33;margin-bottom:20px">本文解锁价格:¥<?php echo $down_price;?></div><a href="javascript:;" style="color:#fff !important;margin-bottom:20px" class="btn erphp-wppay-loader jumppay" data-post="<?php the_ID();?>">立即解锁</a></div>'
});
//return false;
}, longPressTime);
});
$("#article-content").on("touchend touchcancel", function(e) {
clearTimeout(pressTimer);
});
$(document).on('copy', function(e) {
let clipboardData = e.clipboardData || window.clipboardData;
if(!clipboardData) return ;
let text = window.getSelection().toString();
if(text){
e.preventDefault();
}
layer.open({
type: 1,
area: ['360px', ''],
skin: 'layui-layer-dialog',
title: '付费复制',
resize:false,
scrollbar: false,
shadeClose: true,
content: '<div style="text-align:center"><span style="display:inline-block;width:60px;height:60px;border-radius:50%;border:1px solid #999;margin-bottom:20px"><i class="icon icon-copy" style="font-size:36px;line-height:60px"></i></span><div style="font-size:18px;margin-bottom:10px">付费后解锁当前文章复制权限</div><div style="font-size:16px;color:#ff5f33;margin-bottom:20px">本文解锁价格:¥<?php echo $down_price;?></div><a href="javascript:;" style="color:#fff !important;margin-bottom:20px" class="btn erphp-wppay-loader jumppay" data-post="<?php the_ID();?>">立即解锁</a></div>'
});
//return false;
});
});
}


0 个评论