2006/Oct/10

คราวที่แล้วสอน คราวนี้จะบอกวิธีมั่ง จาก http://www.quirksmode.org/js/improt.html
การก๊อปภาพมีสองวิธี
1.คลิกขวา>Save image as
2.ลากใส่ Desktop
3.(เสริม ลากใส่ url แล้วเซฟ)


อันนี้เป็นโค๊ตกันคลิกขวา(แต่ extension allow right click แก้ได้) ให้ใส่ไว้ในแถก <script> หรือไว้ในไฟล์ js ต่างหาก
var specialcase = ((navigator.userAgent.indexOf('Mac') != -1) || document.all)
var flag = 0;
var msg = 'This image is protected by copyright.\nWe request you not to copy it.';
var x,y,x1,y1,copyAttempt;

function init()
{
if (!(document.getElementById || document.all || document.layers)) return;
if (specialcase && document.layers)
{
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = special;
}
for (i=0;i<document.images.length;i++)
{
document.images[i].onmousedown = checkIt;
document.images[i].onmouseup = function() {return false};
if (specialcase)
{
document.images[i].onmousemove = special;
document.images[i].onclick = clearIt;
}
}
}

function checkIt(e)
{
copyAttempt = 0;
if (window.Event)
{
x = e.screenX;
y = e.screenY;
theButt = (e.which == 3);
}
else
{
x = window.event.clientX;
y = window.event.clientY;
theButt = (window.event.button == 2);
}
if (theButt)
{
copyAttempt = 1;
flag = 0;
alert(msg);
return false; // NN4 only
}
if (specialcase) flag = 1;
return false;
}

function special(e)
{
theObj = '';
if (window.Event)
{
x1 = e.screenX;
y1 = e.screenY;
if (e.target.parentNode) theObj = e.target.parentNode.tagName;
}
else
{
x1 = window.event.clientX;
y1 = window.event.clientY;
theObj = window.event.srcElement.parentElement.tagName;
}
var isLink = (theObj == 'A');
if (flag && (!isLink || ((Math.abs(x-x1) > 10) || (Math.abs(y-y1) > 10))))
{
copyAttempt = 1;
flag = 0;
alert(msg);
return false;
}
}

function clearIt()
{
flag = 0;
if (copyAttempt)
{
copyAttempt = 0;
return false;
}


แล้วใส่
<BODY onLoad="init()"> แทน Tag body




ตัวนี้มีข้อเสียคือใช้ allow right click ปลดล็อคได้(พูดไปแล้ว)
แต่ข้อดีคือลากไปใส่หน้าจอหรือ url ไม่ได้ ลองไปประยุกต์ใช้กับโค๊ตล็อคคลิกขวาที่ล็อคได้ผลดู
อ๋อ ข้อเสียอีกข้อคือ ถ้าใส่ภาพเป็นลิงค์จะลากได้ แต่คลิกขวาไม่ได้

edit @ 2006/10/10 16:32:46
ชื่อ: 
เว็บไซต์: 
คอมเมนต์:




smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry
ถ้าอยากขโมยรูปเราก็ view source แล้วหาเอาเลยล่ะ ถึกซะ
เวบพวกห้ามคลิกขวาก็น่ารำคาญเหมือนกันเนอะ
#1  by  • a n i • At 2006-10-10 16:40, 
ถ้าใครไม่ชอบล็อคคลิกขวา ขอให้ไปอ่านอันก่อนหน้านี้ ส่วนถ้าจะล็อค ก็ใช้อันนี้ จะล็อคได้ แต่ก็ยัง view source ได้ ผมใช้วิธี
<!--อย่าทำตัวเป็นพวกไร้การศึกษา-->
มาต่อกันที่บนโค๊ต แล้ว enter มายาวๆ แต่เปลืองที่ แนะนำให้ใส่ไว้ระดับสายตา แล้วภาพให้ใช้ javascript แสดงโค๊ต จะได้หาไม่เจอ
#2  by  WHS At 2006-10-10 17:31, 

<< Home


วิน (vuai-hua-khin)
View full profile