🎜>
測試javascript
window.onload = function() {
var EventUtil = {
addhandler:function(element,type,handler) {
if(element.addEventListenter) {
element.addEventListenter(type) ,處理程序,假);
} else if (element.attachEvent) {
element.attachEvent("on" type,handler);
} else {
element["on" 類型] = handler;
}
},
getEvent:function(event) {
回傳事件? event:window.event;
},
getTarget:function() {
回傳event.target ||事件.srcElement;
},
preventDefault:function () {
if(event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
},
stopPropagation:function() {
if(event.stopPropagation) {
event.stopPropagation();
} else {
event.cancelBuddle = true
}
,
removehandler:function(element,type,handler) {
if(element.removeEventListenter) {
element.addEventListenter(type,handler,false);
} element if (element .detachEvent) {
element.detachEvent("on" type,handler);
} else {
element["on" type] = null;
}
},
getCharCode: function(event) {
if(typeof event.charCode == "number") {
return event.charCode;
} else {
return event.keyCode;
} else {
return event.keyCode;
}
},
getClipboardText: function(event) {
var ClipboardData = event.clipboardData ||視窗.剪貼簿資料;
return ClipboardData.getData("text");
},
setClipboardText: function(event,value) {
if(event.clipboardData) {
return event.clipboardData.setData("text/plain",value);
} else if(window.clipboardData){
return window.clipboardData.setData("text",value);
}
}
}
var textarea = document.forms[0].elements["text"];
var button = document.getElementById("button");
(function() {
function tabForward (event) {
event = EventUtil.getEvent(event);
var target = EventUtil.getTarget(event);
if(target.value.length == target.maxLength) {
var form = target.parentElement;
for(var i=0,len = form.elements.length;iif(form.elements[i ] == target) {
form.elements[i 1].focus();
return ;
}
}
}
}
var textTel1 = document.getElementById("txtTel1");
var textTel2 = document.getElementById("txtTel2"); textTel3 = document.getElementById("TelTel3");
,"keyup",tabForward);
EventUtil.addhandler(textTel2,"keyup",tabForward); .addhandler(textTel3,"keyup",tabForward);
});
} 腳本> 頭>
/> 表格> 身體>