使用者離開沒有操作一段時間提示使用者鎖屏功能
阿新 • • 發佈:2019-01-08
<title>無標題文件</title> <SCRIPT language="JavaScript"> var timerIdle=0; //空閒時間 var timerBusy=0; //倒計時開始 var timerIdle1=2; //系統引數定義超時時間 var timerBusy1=30; //退出時間 function timerTimeout() { timerIdle++; if (timerIdle > timerIdle1) { if (timerBusy == 0) { timerBusy = timerBusy1 + 1; //view timerUI document.getElementById("timerUI").style.display = "inline"; // alert("鎖屏了哦!親"); } timerBusy--;
//view timerBusy
document.getElementById("_timerBusy").innerHTML = timerBusy; if (timerBusy <= 0) { timerExit(); return; } } else { timerBusy = 0; } window.setTimeout("timerTimeout()", 1000); } function timerUser() {
//讓div消失
timerIdle=0;
document.getElementById("timerUI").style.display="none";
}
//無操作時
function timerExit()
{
//超時處理.這裡可以寫自己需要執行的方法…
// document.getElementById("_timerBusy").innerHTML="Timeout"; // alert("鎖屏了哦。親!"); alert("鎖屏了哦!親"); } window.setTimeout("timerTimeout()",1000); function mouseMove(ev) { ev= ev || window.event; timerUser(); var mousePos = mouseCoords(ev); } function mouseCoords(ev) { if(ev.pageX || ev.pageY){ return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, y:ev.clientY + document.body.scrollTop - document.body.clientTop }; } document.onmousemove = mouseMove; document.onkeydown = mouseMove; </SCRIPT>
您好,您好您好
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td nowrap align="right"><img src="images/loading/6.gif"></td>
<td nowrap align="right" ID="_timerBusy" style=" font-size:36px; font-weight:bold; color:#FF0000;"></td>
<td nowrap align="left"> 秒後將退出系統</td>
</tr>
<tr>
<td nowrap align="right"></td>
<td nowrap align="right"></td>
<td nowrap align="left"> 如繼續操作點任意鍵即可</td>
</tr>
<tr>
<td nowrap align="right"></td>
<td nowrap align="right"></td>
<td nowrap align="left"> (系統檢測到您長時間未進行任何操作,為保護您的資訊保安將自動退出)</td>
</tr>
</table>