复制代 代码如下: テスト JavaScript <br>window.onload = function() { <br>var EventUtil = { <br>addhandler:function(element,type,handler) { <br>if(element.addEventListenter) { <br>element.addEventListenter(type) 、ハンドラー、false); <br>} else if (element.attachEvent) { <br>element.attachEvent("on" type,handler); <br>} else { <br>element["on" type] = ハンドラー; <br>} <br>}, <br><br>getEvent:function(event) { <br>return event?event:window.event; <br>}, <br><br>getTarget:function() { <br>returnevent.target ||イベント.src要素; <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(typeofevent.charCode == "number") { <br>return event.charCode; <br>} else { <br>returnevent.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;iif(form.elements[i] == target) { <br>form.elements[i 1].focus(); <br> >} <br>} <br><br>} <br><br>var textTel1 = document.getElementById("txtTel1"); <br>var textTel2 = document.getElementById("txtTel2"); textTel3 = document.getElementById("txtTel3"); <br><br>EventUtil.addhandler(textTel1,"keyup",tabForward); <br>EventUtil.addhandler(textTel2,"keyup",tabForward); .addhandler(textTel3,"keyup",tabForward); <br>} <br>