Develop and Download Open Source Software

Browse Subversion Repository

Contents of /js/pseudo_behaviour.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (show annotations) (download) (as text)
Fri Dec 4 12:17:36 2009 UTC (14 years, 5 months ago) by berupon
File MIME type: application/x-javascript
File size: 1633 byte(s)
まだ完成していないけど途中経過の記録というか…backupとしてcommit
1
2 // 入力制限の為、IEのビヘイビア的にINPUTにイベントハンドラを付加する
3
4
5 // original : http://tockri.blog78.fc2.com/blog-entry-119.html
6 function pressedChar(event)
7 {
8 var code = 0;
9 if (event.charCode === 0) {
10 // Firefox, Safari control code
11 code = 0;
12 }else if (!event.keyCode && event.charCode) {
13 // Firefox
14 code = event.charCode;
15 }else if (event.keyCode && !event.charCode) {
16 // IE
17 code = event.keyCode;
18 }else if (event.keyCode == event.charCode) {
19 // Safari
20 code = event.keyCode;
21 }
22
23 if (32 <= code && code <= 126) {
24 // ASCII文字の範囲内
25 return String.fromCharCode(code);
26 }else {
27 return null;
28 }
29 }
30
31 function cancelEvent(event, cancel)
32 {
33 if (event.preventDefault) {
34 if (cancel) {
35 event.preventDefault();
36 }
37 }else {
38 if (cancel) {
39 event.returnValue = false;
40 }
41 }
42 }
43
44 if (!behaviourAssignors) {
45 var behaviourAssignors = {};
46 }
47
48 function assignBehaviours()
49 {
50 var cnt = document.forms.length;
51 for (var i=0; i<cnt; ++i) {
52 var form = document.forms[i];
53 var cnt2 = form.elements.length;
54 for (var j=0; j<cnt2; ++j) {
55 var elem = form.elements[j];
56 if (elem.className) {
57 // alert(elem.className);
58 var assignor = behaviourAssignors[elem.className];
59 // alert(assignor);
60 if (assignor) {
61 assignor(elem);
62 }
63 }
64 }
65 }
66 }
67
68 // execute later to avoid influence of other startup modifiers. (some replace or overwrite innerHTML and kill later-attached eventListeners.)
69 Event.observe(window, "load", assignBehaviours);
70 //document.observe('dom:loaded', assignBehaviours);

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26