[TUTORIAL] How to disable text selection - Protect your content!
2014-04-15, 03:33 PM, (This post was last modified: 2014-04-16, 02:55 AM by k1zz.)
#1
Hello elites, i found a good script for disabling text selection and i thought to share it with you. It works well if you want to protect your content by copy/paste.

[hide]Add this script to the HEAD section of your page:
Code:
<script type="text/javascript">

/***********************************************
* Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
    target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
    target.style.MozUserSelect="none"
else //All other route (ie: Opera)
    target.onmousedown=function(){return false}
target.style.cursor = "default"
}

//Sample usages
//disableSelection(document.body) //Disable text selection on entire body
//disableSelection(document.getElementById("mydiv")) //Disable text selection on element with id="mydiv"

</script>
With the script installed, just call the function disableSelection(target) at the very end of the document with a reference to the element you wish to disable text within. An example:
Code:
<script type="text/javascript">
var somediv=document.getElementById("mydiv")
disableSelection(somediv) //disable text selection within DIV with id="mydiv"
</script>

Source: Dynamic Drive[/hide]
Reply
Share This Thread :

2014-04-15, 09:20 PM,
#2
Thanks for the share
Reply
2014-04-15, 09:30 PM,
#3
Thank You for this share.
Reply
2014-04-15, 10:31 PM,
#4
Thanks for share buddy . This will help a lot of newcomers.
Reply
2014-04-16, 01:16 AM,
#5
thanks mate really needed it
Reply
2014-04-16, 06:09 AM,
#6
Fantastic, thanks you very much brother :)
Reply
2014-04-16, 06:44 AM,
#7
Won't be useful if the guy who wants to copy your site has some HMTL expierence as he can easily visits the source code document of your site and copy it from there. But still a useful script :P
Reply
2014-04-16, 01:59 PM,
#8
(2014-04-16, 06:44 AM)pwned Wrote: Won't be useful if the guy who wants to copy your site has some HMTL expierence as he can easily visits the source code document of your site and copy it from there. But still a useful script :P

That person works more, not just copy/paste Tongue
Reply


Related Threads
Thread Author Replies Views Last Post
  [HQ Tutorial]»» Boost your conversions/CTR - add a countdown to your landing page «« allnet 68 10,965 2018-07-18, 07:58 PM
Last Post: YoBroGo
  [Tutorial] How to make unlimited YouTube accounts if you have static IP Andrei 58 6,994 2018-07-16, 07:50 PM
Last Post: ferb67
  RIP Unlist Method - Alternative Methods (Tutorial) :) alexparris 70 9,204 2018-07-13, 01:23 PM
Last Post: Tyrone
  [UNSEEN METHOD] Make $2000 a Month on AUTOPILOT with Viral Content and Ads Ryan2kc 87 13,233 2018-07-10, 01:34 PM
Last Post: Sami252
  [Tutorial]Easy Whitehat Niches ideas MrZeus 70 13,445 2018-07-06, 04:03 PM
Last Post: biocryol77





About Us | Contact Us | CPA Elites | Advertise | Stats

© 2013-2018 CPA Elites Ltd
Enhanced by MyBB and WallBB
Return to top