Wednesday, May 2, 2007

Disabling Text Selection For Drag-Drop

I just found one blog that is quite useful. It is about how to prevent unintentional text selection during drag-and-drop. Take a look of this blog: http://www.ajaxcf.com/blog/index.cfm/2007/4/17/Disabling-Text-Selection-For-DragandDrop.
Thanks to Joe Danziger that posted this topic.

<script type="text/javascript">
function disableSelection(element) {
element.onselectstart = function() {
return false;
};
element.unselectable = "on";
element.style.MozUserSelect = "none";
element.style.cursor = "default";
}
</script>
<script type="text/javascript">
disableSelection(document.getElementById("text"));
</script>

No comments:

Subscribe in a Reader