onselectstart="return false;" (關閉滑鼠選取功能)
oncontextmenu="window.event.returnValue=false;" (不顯示滑鼠右鍵選單)
按右鍵時會出現顯示警語
oncontextmenu="window.event.returnValue=false;alert('版權所有')"
範例1 所有內容:
<body ondragstart="return false" onselectstart="return false" onContextMenu="return false"></body>
範例2 其中一段內容
<div ondragstart="return false" onselectstart="return false" onContextMenu="return false">
文章內容...</div>
右鍵只鎖圖片
<SCRIPT Language="JavaScript">
var clickmessage="圖片請自找 謝謝您"
function disableclick(e) {if (document.all) {if (event.button==2||event.button==3) {if (event.srcElement.tagName=="IMG"){alert(clickmessage);
return false;}}}if (document.layers) {if (e.which == 3) {alert(clickmessage);return false;}}}function associateimages(){for(i=0;i<document.images.length;i++)document.images.onmousedown=disableclick;}if (document.all)document.onmousedown=disableclick
else if (document.layers)associateimages()</SCRIPT>
防左鍵(不能反白)防右鍵而且還是無工具列視窗
<SCRIPT language=JavaScript>
<!-- begin
document.onmousedown=click;
document.onkeydown=click;
if (document.layers) window.captureEvents(Event.MOUSEDOWN); window.onmousedown=click;
if (document.layers) window.captureEvents(Event.KEYDOWN); window.onkeydown=click;
function click(e){
if (navigator.appName == 'Netscape'){
if (e.which != 1){
alert("是不是連鍵盤都無法使用啦?");
return false;}}
if (navigator.appName == "Microsoft Internet Explorer"){
if (event.button != 1){
alert("是不是連鍵盤都無法使用啦?");
return false;}}}
// end -->
</SCRIPT>
請先 登入 以發表留言。