禁止右键,禁止拖曳,禁止选择,禁止网页另存为
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<script language="JavaScript">
<!--
//***********************禁止右键***************************
if (window.Event)
document.captureEvents(Event.MOUSEUP);
function nocontextmenu()
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
function norightclick(e)
{
if (window.Event)
{
if (e.which == 2 || e.which == 3)
return false;
}
else
if (event.button == 2 || event.button == 3)
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
}
//************************禁止选择***************************
function noSelect()
{
return false;
}
//************************禁止拖曳***************************
function noDragstart()
{
return false;
}
//************************清空剪切板*************************
function keyDown()
{
var iekey = event.keyCode;
//alert(iekey);
if(iekey == 42)
{
//window.clipboardData.setData('img','')
window.clipboardData.clearData();
}
}
//-->
</script>
<!--禁止网页另存为-->
<noscript> <iframe src="*.htm"></iframe> </noscript>
<noscript> <iframe src="*.htm"></iframe> </noscript><SCRIPT language=JavaScript>
document.oncontextmenu = nocontextmenu;
document.onmousedown = norightclick;
document.ondragstart = noDragstart;
document.onselectstart = noSelect;
document.onselect = document.selection.empty();
document.onkeydown = keyDown;
</SCRIPT>