Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function kill_ctrl_key_combo(e) {
- var forbiddenKeys = new Array('a', 'c', 'x', 's', 'u');
- var key;
- var isCtrl;
- if (window.event) {
- key = window.event.keyCode;
- if (window.event.ctrlKey) isCtrl = true;
- else isCtrl = false;
- } else {
- key = e.which;
- if (e.ctrlKey) isCtrl = true;
- else isCtrl = false;
- }
- //if ctrl is pressed check if other key is in forbidenKeys array
- if (isCtrl) {
- for (i = 0; i < forbiddenKeys.length; i++) { //case-insensitive comparation
- if (forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase()) {
- return false;
- }
- }
- }
- return true;
- }
- function disable_selection(target) {
- if (typeof target.style.MozUserSelect != "undefined") {
- target.style.MozUserSelect = "none";
- }
- target.style.cursor = "default";
- }
- function double_mouse(e) {
- if (e.which == 2 || e.which == 3) {
- return false;
- }
- return true;
- }
- function enable_protection() {
- disable_selection(document.body); //These will disable selection on the page
- document.captureEvents(Event.MOUSEDOWN);
- document.onmousedown = double_mouse; //These will disable double mouse on the page
- document.oncontextmenu = function() {
- return false;
- }; //These will disable right click on the page
- document.onkeydown = kill_ctrl_key_combo;
- }
- window.onload = function() { //These will enable protection on the page
- enable_protection();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement