Copyrights @ Journal 2014 - Designed By Templateism - SEO Plugin by MyBloggerLab

Friday, July 06, 2007

Disable drag and Text selection in Firefox


Firefox is known to support most of the W3C Dom standards and IE is usually to support most non standard or I would say "IE Standard". Anyways, I still like IE because my website is viewed by mostly IE users, almost over 85%.

I had seen some people copying text from website, so I wanted to implement no drag and copy text from my website. Here is what I added to the body tag of each HTML rendered page on my site. (I know there are other ways to copy. :( )

onmousedown="javascript:clickTrap();" ondragstart="return false" ondblclick="return false" onselectstart="return false"

This stopped drag and text selection for every IE visitor on my site. Easy and simple technique allowed me to achieve what I wanted. Still there were about 15% "Standard Browser" based non standard users. They could drag and select text from my site. Searching paid off after a long time. Mozilla based browsers need to you to create a javascript event handler routine to stop the drop or use this non-standard, browser specific tags. Here is what I did. You can leave them in your CSS file because IE just ignores them and Firefox will block the drag.

        -moz-user-focus: ignore;    
        -moz-user-input: disabled;    
        -moz-user-select: none;
<input class="protectedText" type="text" value="Change this"> 
<span class="protectedText">sdaf</span>

Find other such tags, that mught be useful for you.