Top visit: https://blogjak.com
In this session, I will cover how to stop content theft by using JQuery. Users cannot cut/copy a part or whole contents of your website.
You make a new file and save it as j-query.disable.select.js in your folder or main root. Here is the code:
(function($) {
if ($.browser.mozilla) {
$.fn.disableTextSelect = function() {
return this.each(function() {
$(this).css({
'MozUserSelect' : 'none'
});
});
};
$.fn.enableTextSelect = function() {
return this.each(function() {
$(this).css({
'MozUserSelect' : ''
});
});
};
} else if ($.browser.msie) {
$.fn.disableTextSelect = function() {
return this.each(function() {
$(this).bind('selectstart.disableTextSelect', function() {
return false;
});
});
};
$.fn.enableTextSelect = function() {
return this.each(function() {
$(this).unbind('selectstart.disableTextSelect');
});
};
} else {
$.fn.disableTextSelect = function() {
return this.each(function() {
$(this).bind('mousedown.disableTextSelect', function() {
return false;
});
});
};
$.fn.enableTextSelect = function() {
return this.each(function() {
$(this).unbind('mousedown.disableTextSelect');
});
};
}
})(jQuery);
And then you need jquery-1.4.js to operate it well. You also may put this script into body or div.
<html>
<head>
<script type="text/javascript" src="jquery-1.4.js"></script>
<script type="text/javascript" src="jquery.disable.select.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.selection').disableTextSelect();
});
</script>
</head>
<body class="selection">
Yang membuatku terus berkembang adalah tujuan-tujuan hidupku. <br>
- Muhammad Ali
</body>
</html>