防止刷新和后退的js
2009-09-17 15:26 xiaosuo 阅读(322) 评论(0) 编辑 收藏 举报<script language="JavaScript">
function onKeyDown()
{
if ( (event.altKey) || ((event.keyCode == 8) &&
(event.srcElement.type != "text" &&
event.srcElement.type != "textarea" &&
event.srcElement.type != "password")) ||
((event.ctrlKey) && ((event.keyCode == 78) || (event.keyCode == 82)) ) ||
(event.keyCode == 116) )
{
event.keyCode = 0;
event.returnValue = false;
}
}
document.onkeydown = onKeyDown;
function stop(){
return false;
}
document.oncontextmenu=stop;
</script>