On copy prevention in HTML, part 1

Migrated from my old blog; originally posted 4/8/2007

Many web developers like to prevent their viewers from copying their text. While I do not approve of this, there are cases where it is appropriate.

The simplest way to achieve this is to use the IE only attribute UNSELECTABLE and the FireFox only css style -moz-user-select. Such HTML looks like this:

<DIV unselectable="on"
You can't select me.
You can't select me.

To make the HTML and CSS validate, one could do this in Javascript: Elem.unselectable = "on"; Elem.style.MozUserSelect = "none";

However, this method only works in IE and Firefox. In addition, in IE, it doesn't work very well, and if a user tries hard, he will end up selecting the text.

A slightly better way to do it is to handle the onselectstart event (for IE) and the onmousedown event (for everything else) and return false. This will prevent the browser from handling the events. This results in something like this:

onselectstart="return false;"
onmousedown="return false;" >
You can't select me.
You can't select me.

The problem with these methods is that they do nothing to prevent a user from reading the HTML source. This is discussed in the next part.


It's nice that there are such blogs. Karina

It will be great idea for college students to read information from https://eduessayhelper.org/blog/sat-score. Here you can read how to get higher SAT score

ارخص شركة نقل عفش

ارخص شركة نقل عفش بالمدينة المنورة نقل عفش بالمدينة المنورة
ارخص شركة نقل عفش بمكة نقل عفش بمكة
شركة نقل عفش شركة نقل عفش

ارخص شركة نقل عفش بجدة نقل عفش بجدة
دينا نقل عفش جدة دينا نقل عفش بجدة

Hi there! I am extremely proud that our generation is so positive about innovative technologies, thank you for sharing great content. It is wonderful to watch this. To develop our talents, we need to learn something new every day of our life. In our time, learning has become both more difficult and easier, harder because curriculum is improving but the level of necessary knowledge is growing. It’s easier because the guys from https://bestresearchpaper.com/ continue to help students solve problems of varying complexity.

Very informative blog, and beautifully elaborating the complete information about the topic. We are from the same domain emerging as the top mobile app development company for versatile app creation services. You can email us at sales@appsquadz.com or Phone Number: +91-9717270746

Post a Comment