提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
一、禁用右键
代码如下(示例):
// 右クリックを無効にする
document.body.onselectstart =
document.body.oncontextmenu =
function () {
// ブラウザのデフォルト操作をキャンセル
return false;
};
二、禁用ctrl+c,ctrl+v
代码如下(示例):
window.onload = function(){
document.onkeydown = function(event){
if (event.ctrlKey && window.event.keyCode==67){
console.log("シールドctrl+c");
return false;
}
if (event.ctrlKey && window.event.keyCode==86){
console.log("シールドctrl+v");
return false;
}
}
}
三、禁止返回上一页
代码如下(示例):
// 前のページに戻ることを禁止
if (window.history && window.history.pushState) {
$(window).on('popstate', function () {
window.history.pushState('forward', null, '#');
window.history.forward(1);
});
}
if ('pushState' in history) {
window.history.pushState('forward', null, '#');
window.history.forward(1);
}else{
History.pushState('forward', null, '?state=2');
window.history.forward(1);
}
window.onhashchange=function(){
History.pushState('forward', null, '?state=1');
}