• slider image 285
:::
windelf - 數位學習 | 2017-08-12 | 點閱數: 381

防止反白網頁的 CSS
在網頁中的</head>標簽之前添加以下 CSS 代碼

<style type="text/css">body {
-moz-user-select : none;
-webkit-user-select: none;
}
</style>

然後在網頁中插入或調用以下 JS 代碼

<script type="text/javascript">
function iEsc(){ return false; }
function iRec(){ return true; }
function DisableKeys() {
if(event.ctrlKey || event.shiftKey || event.altKey) {
window.event.returnValue=false;
iEsc();}
}
document.ondragstart=iEsc;
document.onkeydown=DisableKeys;
document.oncontextmenu=iEsc;
if (typeof document.onselectstart !="undefined")
document.onselectstart=iEsc;
else{
document.onmousedown=iEsc;
document.onmouseup=iRec;
}
function DisableRightClick(qsyzDOTnet){
if (window.Event){
if (qsyzDOTnet.which == 2 || qsyzDOTnet.which == 3)
iEsc();}
else
if (event.button == 2 || event.button == 3){
event.cancelBubble = true
event.returnValue = false;
iEsc();}
}
</script>

來源網址
https://3q.9527.tw/79