No Copy Script for html page
One of my clients would like a No Copy Script on there website to prevent people copying the text off the page. Is there a cross browser wa开发者_C百科y you can do this? I would probably just look at a JavaScript method. I know this can be turned off by people with a bit of knowhow but will do for most cases.
There are ton of resources on the Internet about this request. Mind that a determined user will always be able to copy the text from a webpage.
<script language="JavaScript">
// distributed by http://hypergurl.com <!-- var popup="Sorry, right-click
is disabled.\n\nThis Site Copyright ©2000"; function noway(go) { if
(document.all) { if (event.button == 2) { alert(popup); return false; } } if (document.layers)
{ if (go.which == 3) { alert(popup); return false; } } } if (document.layers)
{ document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=noway; // -->
</script>
<script language="JavaScript1.1">
// distributed by http://www,hypergurl.com <!-- var debug = true; function
right(e) { if (navigator.appName == 'Netscape' && (e.which == 3 || e.which
== 2)) return false; else if (navigator.appName == 'Microsoft Internet Explorer'
&& (event.button == 2 || event.button == 3)) { alert('This Page is fully
protected!'); return false; } return true; } document.onmousedown=right; if (document.layers)
window.captureEvents(Event.MOUSEDOWN); window.onmousedown=right; //--></script>
Not an answer but this what I think about the subject:
If you want people not to copy content of your site then don't post it on the Internet. javascript will prevent the user from selection but the users will be annoyed. (e.g. I sometimes select text to make the reading easier, instead of copying it)
People will still get the text via the HTML source/DOM. People can retype the text or make a picture and use OCR.
<script language=JavaScript>
var message="!!YOU CANNOT COPY ANY TEXT OR IMAGE FROM THIS SITE!";
function clickIE4()
{
if (event.button==2)
{
alert(message);
return false;
}
}
function clickNS4(e)
{
if (document.layers||document.getElementById&&!document.all)
{
if (e.which==2||e.which==3)
{
alert(message);
return false;
}
}
}
if (document.layers)
{
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById)
{
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
</script>
</head>
<body>
精彩评论