Sunday, April 19, 2009

Javascript code for preventing user from copying content from webpage.


Find below the javascript code for disabling Mouse right click in web browser to prevent user from copying the content.

Buy anyway the content can be copied from many other ways such as from view source.

This code won't help if the user disables the javascript in his browser.

I am just curious to know whether any code/way available to prevent webpage content copying completely.





<script language='JavaScript1.2'>
function disableselect(e){

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


More Articles...

12 comments:

Anonymous said...

In order to display the webpage, you have to send the content to the user. At this point, the user can do whatever they like to it.

This is a fundamental fact, and the only way to change it is to own the computer the user is using.

So, no, there is no such Javascript code. Why would a web browser allow you to write such code, after all, when they work for the user, not you?

Anonymous said...

It's impossible to completely prevent copying. Once the page's content has been sent to the user's computer, you can't control what they do with it.

There are programs that will take a URL and download the content from it, and save it to disk, no matter what type of content it is or what code it contains.

Anonymous said...

This has to be joke? How can you block the contents of a web page and still have it rendered in a browser? You can't possibly write javascript and not know this?

Anonymous said...

Render each character like a CAPTCHA image like I have to do for word verification to send this comment. Then the text can only be copied by re-typing.

JamesF said...

You could render the entire page server-side and send them a JPG screenshot, thus increasing the work required to rip individual elements. Of course, there are so many downsides to doing this I don't know where to start..

Anonymous said...

No. This is kind of obvious.

Jason Sares said...

One word --- flash...

Anonymous said...

Yea, flash came to my mind too.

Anonymous said...

I don't need a mouse to copy and paste the content. Never heard of Ctrl+C?

a said...

That is a horrible way to prevent copying. It is incredibly easy to work around and only gets in the way of valid users. I do a lot more than copy with right click.

In no way is it worth it.

Unknown said...

this is insane... it's only reduces usability for the client. there are many useful feature in the right click menu and many other way to copy content. this script snippet was used in the beginning of the web and I haven't seen it since 10 years or so because it's useless

Upendra Chansoria said...

Someone Steal my website content but i ma unable to prvent it ............give me the exact ways

Search This Blog