复制代码 代码如下: test javascript <BR>window.onload = function() { <BR>var EventUtil = { <BR>addhandler:function(element,type,handler) { <BR>if(element.addEventListenter) { <BR>element.addEventListenter(type,handler,false); <BR>} else if (element.attachEvent) { <BR>element.attachEvent("on"+type,handler); <BR>} else { <BR>element["on"+type] = handler; <BR>} <BR>}, <br><br>getEvent:function(event) { <BR>return event?event:window.event; <BR>}, <br><br>getTarget:function() { <BR>return event.target || event.srcElement; <BR>}, <br><br>preventDefault:function() { <BR>if(event.preventDefault) { <BR>event.preventDefault(); <BR>} else { <BR>event.returnValue = false; <BR>} <BR>}, <br><br>stopPropagation:function() { <BR>if(event.stopPropagation) { <BR>event.stopPropagation(); <BR>} else { <BR>event.cancelBuddle = true; <BR>} <BR>}, <br><br>removehandler:function(element,type,handler) { <BR>if(element.removeEventListenter) { <BR>element.addEventListenter(type,handler,false); <BR>} else if (element.detachEvent) { <BR>element.detachEvent("on"+type,handler); <BR>} else { <BR>element["on"+type] = null; <BR>} <BR>}, <br><br>getCharCode: function(event) { <BR>if(typeof event.charCode == "number") { <BR>return event.charCode; <BR>} else { <BR>return event.keyCode; <BR>} <BR>}, <br><br>getClipboardText: function(event) { <BR>var clipboardData = event.clipboardData || window.clipboardData; <BR>return clipboardData.getData("text"); <BR>}, <br><br>setClipboardText: function(event,value) { <BR>if(event.clipboardData) { <BR>return event.clipboardData.setData("text/plain",value); <BR>} else if(window.clipboardData){ <BR>return window.clipboardData.setData("text",value); <BR>} <BR>} <br><br>} <br><br>var textarea = document.forms[0].elements["text"]; <BR>var button = document.getElementById("button"); <br><br><BR>(function() { <BR>function tabForward(event) { <BR>event = EventUtil.getEvent(event); <BR>var target = EventUtil.getTarget(event); <br><br>if(target.value.length == target.maxLength) { <BR>var form = target.parentElement; <br><br>for(var i=0,len = form.elements.length;i<len-1;i++) { <BR>if(form.elements[i] == target) { <BR>form.elements[i+1].focus(); <BR>return ; <BR>} <BR>} <BR>} <br><br>} <br><br>var textTel1 = document.getElementById("txtTel1"); <BR>var textTel2 = document.getElementById("txtTel2"); <BR>var textTel3 = document.getElementById("txtTel3"); <br><br>EventUtil.addhandler(textTel1,"keyup",tabForward); <BR>EventUtil.addhandler(textTel2,"keyup",tabForward); <BR>EventUtil.addhandler(textTel3,"keyup",tabForward); <br><br>})(); <BR>} <BR>