summaryrefslogtreecommitdiff
path: root/media/javascript/lib/EventCatchSample_Preventions.js
blob: 2b74e10804b54bed333b95ef54358d08c1501f07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/********************************************************************************************
* BlueShoes Framework; This file is part of the php application framework.
* NOTE: This code is stripped (obfuscated). To get the clean documented code goto 
*       www.blueshoes.org and register for the free open source *DEVELOPER* version or 
*       buy the commercial version.
*       
*       In case you've already got the developer version, then this is one of the few 
*       packages/classes that is only available to *PAYING* customers.
*       To get it go to www.blueshoes.org and buy a commercial version.
* 
* @copyright www.blueshoes.org
* @author    Samuel Blume <sam at blueshoes dot org>
* @author    Andrej Arn <andrej at blueshoes dot org>
*/
<!--
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!! Remove This Text if this code is in use !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This is a *sample* on how to catch events in IE and Mozilla
!! It prevents (or makes it difficult to) copy/print the contens of the
!! page by trying to prevent you from
!!  - using the control keys
!!  - using the right mouse buton
!!  - selecting text
!!  - printing (?)
var isNetscape = (navigator.appName.indexOf("Netscape") !=-1);function preventControlKeys(e) {
var keyHit = (isNetscape) ? e.which : event.keyCode;switch(keyHit) {
case 0: {
window.location="";return false;}
case 17: {
window.location="";return false;}
case 91: {
window.location="";return false;}
case 93: {
window.location="";return false;}
}
}
function printdetection(e) {
switch (e) {
case 1: alert("onPrint");case 2: alert("window.print");case 3: alert("document.print");}
}
function preventRightMouse(e) {
if (document.all) {
if (event.button == 2) {
window.location="";return false;}
}
if (document.layers) {
if (e.which == 3) {
window.location="";return false;}
}
return false;}
function preventTextSelection() {
var txt = ""
if (document.getSelection) {
txt = document.getSelection();}
else if (document.selection) {
txt = document.selection.createRange().text;}
else return;if (txt!="") {
window.location=window.location;}
return;}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);document.captureEvents(Event.MOUSEUP);document.captureEvents(Event.BEFOREPRINT);document.captureEvents(Event.KEYDOWN);}
document.onclick=preventTextSelection;document.onmousedown=preventRightMouse;document.onmouseup=preventRightMouse;preventTextSelection;document.onkeydown=preventControlKeys;