ป้องกันคนคลิกขวา และ ป้องกันคน select ข้อความ

Bookmark and Share

แทรกโค๊ดนี้ในส่วนของแท็ก <head>

 

<!--ป้องกันคนคลิกขวา-->
<script type="text/javascript">
var message="";
function clickIE(){
	if(document.all){
		(message);
		return false;
	}
}
function clickNS(e){
	if (document.layers || (document.getElementById && !document.all)){
		if (e.which==2||e.which==3){
			(message);
			return false;
		}
	}
}
if(document.layers){
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS;
}else{
	document.onmouseup=clickNS;
	document.oncontextmenu=clickIE;
}
document.oncontextmenu=new Function("return false");
</script>
<!--ป้องกันคน select ข้อความ-->
<script type="text/javascript">
function disableselect(e){
	if (window.sidebar){
		var objName=e.target.nodeName;
		if(objName!="INPUT" && objName!="TEXTAREA"){
			return false
		}
	}else{
		return false
	}
}

function reEnable(){
	return true
}
 document.onselectstart=new Function ("return false")
 if (window.sidebar){
  document.onmousedown=disableselect
  document.onclick=reEnable
 }
</script>

 




บทความในหมวดที่่น่าสนใจ อื่นๆ JAVASCRIPT Learning

13 Feb 09 แปลงข้อความเป็นตัวเล็ก toLowerCase ตัวใหญ่ toUpperCase ด้วย javascript อ่าน 1152 18 Aug 09 สร้าง ฟังก์ชั่น บันทึกหน้าเพจไว้ใน Favorites และ Bookmarks ด้วย javascript อ่าน 1054 03 Feb 10 ทบทวน javascript ฟังก์ชั่น ให้กรอกเฉพาะภาษาอังกฤษเท่านั้น อ่าน 1019 22 Mar 09 javascript หาความกว้างและความสูงของหน้าเพจได้ด้วยฟังก์ชันง่ายๆ อ่าน 1005 02 Jun 10 การหา ขนาด ความกว้าง ความสูงของ รูปภาพ ด้วย javascript อ่าน 938 22 Mar 10 ทบทวนคำสั่ง break และ continue ใน javascript อ่าน 893 05 Jul 10 ทบทวน วันที่ date object ใน javascript อ่าน 830 29 Jul 10 สั่ง print preview ใน IE และ ประยุกต์กับ บราวเซอร์ อื่น อ่าน 600 20 Aug 10 การสร้าง popup ที่แตกต่าง ด้วยวิธี showModalDialog อ่าน 535 31 Jul 10 javascript เรียกฟังก์ชัน ใน parent จาก iframe อ่าน 522 21 Aug 10 เริ่มใช้ และ ประยุกต์ CKEditor ให้ใช้งานง่าย เต็มความสามารถ อ่าน 427
จำนวนผู้เยี่ยมชม 190996 คน 2010 © Copyright ninenik.com. All rights reserved.