Để hạn chế người dùng copy dữ liệu từ diễn đàn, website bạn có rất nhiều cách. Dưới đây là một cách. Hãy chèn đoạn mã dưới vào website bạn muốn bảo vệ. Sẽ hạn chế khi người dùng view source , copy bài viết, hình ảnh ...
var message="Text Here";
function click(e)
{
if (document.all)
{
if (event.button==2||event.button==3)
{
alert(message);
return false;
}
}
else
{
if (e.button==2||e.button==4)
{
e.preventDefault();
e.stopPropagation();
alert(message);
return false;
}
}
}
if (document.all) // for IE
{
document.onmousedown=click;
}
else // for FF
{
document.onclick=click;
}
function ehan( evnt )
{
if( evnt.which == 3 )
{
alert( "Text Here" );
return false;
}
return true;
}
function ocmh()
{
alert( "Text Here" );
return false;
}
document.oncontextmenu = ocmh;
document.captureEvents( Event.MOUSEDOWN );
if( document.layers ) document.onmousedown = ehan;
if (window!=top){top.location.href=location.href;}
if (window!=top){top.location.href=location.href;}