1、鼠標右鍵觸發事件
function click()
{
if(event.button==2)
{
alert('hello。。。。。。')
}
}
document.onmousedown=click
2、讓鼠標右鍵失效
<body oncontextmenu=self.event.returnValue=false>
3、是頁面文字內容無法選擇或全選
<body ondragstart="window.event.returnValue=false" oncontextmenu="window.event.returnValue=false" onselectstart="event.returnValue=false">
4、利用js實現 禁用瀏覽器后退
//回退時候產生一個前進事件
<script>
javascript:window.history.forward(1);
</script>
或者如下方式:
<script language="javascript">
//防止頁面后退
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function () {
history.pushState(null, null, document.URL);
});
</script>
