<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="JavaScript" >
<!--
//定义监听器
var oEventUtil = new Object();
oEventUtil.AddEventHandler = function(oTarget,sEventType,fnHandler){
if(oTarget.addEventListener){
oTarget.addEventListener(sEventType,fnHandler,false);
} else if(oTarget.attachEvent) {
oTarget.attachEvent('on'+sEventType,fnHandler);
} else{
oTarget['on'+sEventType] = fnHandler;
}
};
//回调函数,获得焦点时变为红色
var oTF = function() {
var oEvent = arguments[0];
var oTarget = oEvent.target || oEvent.srcElement;
oTarget.style.color="#ff0000";
}
//失去焦点时变为黑色
var oTB = function()
{
var oEvent = arguments[0];
var oTarget = oEvent.target || oEvent.srcElement;
oTarget.style.color="#000000";
}
-->
</script>
</HEAD>
<BODY>
<form name="form1" method="POST" >
<input type="text" name="nhn1" value="nhn1" >
<input type="text" name="nhn1" value="nhn2" >
<input type="text" name="nhn1" value="nhn3" >
<input type="text" name="nhn1" value="nhn4" ><br/>
<input type="text" name="nhn1" value="nhn5" >
<input type="text" name="nhn1" value="nhn6" >
<input type="text" name="nhn1" value="nhn7" ><br/>
<input type="text" name="nhn1" value="nhn8" >
<input type="text" name="nhn1" value="nhn9" >
<input type="text" name="nhn1" value="nhn10" ><br/>
<input type="text" name="nhn1" value="nhn11" >
<input type="text" name="nhn1" value="nhn12" >
<input type="text" name="nhn1" value="nhn13" ><br/>
<input type="text" name="nhn1" value="nhn14" >
<input type="text" name="nhn1" value="nhn15" >
<input type="text" name="nhn1" value="nhn16" ><br/>
<input type="text" name="nhn1" value="nhn17" >
<input type="text" name="nhn1" value="nhn18" >
<input type="text" name="nhn1" value="nhn19" ><br/>
<input type="button" name="bbb" value="button" οnclick="test()" >
</form>
</BODY>
</HTML>
<script language="JavaScript" >
//给页面的文本元素加上监听器
var form=document.forms[0];
for(var i=0;i<form.length;i++){
if(form.elements[i].type=="text"){
oEventUtil.AddEventHandler(form.elements[i],'focus',oTF);
oEventUtil.AddEventHandler(form.elements[i],'blur',oTB);
}
}
</script>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="JavaScript" >
<!--
//定义监听器
var oEventUtil = new Object();
oEventUtil.AddEventHandler = function(oTarget,sEventType,fnHandler){
if(oTarget.addEventListener){
oTarget.addEventListener(sEventType,fnHandler,false);
} else if(oTarget.attachEvent) {
oTarget.attachEvent('on'+sEventType,fnHandler);
} else{
oTarget['on'+sEventType] = fnHandler;
}
};
//回调函数,获得焦点时变为红色
var oTF = function() {
var oEvent = arguments[0];
var oTarget = oEvent.target || oEvent.srcElement;
oTarget.style.color="#ff0000";
}
//失去焦点时变为黑色
var oTB = function()
{
var oEvent = arguments[0];
var oTarget = oEvent.target || oEvent.srcElement;
oTarget.style.color="#000000";
}
-->
</script>
</HEAD>
<BODY>
<form name="form1" method="POST" >
<input type="text" name="nhn1" value="nhn1" >
<input type="text" name="nhn1" value="nhn2" >
<input type="text" name="nhn1" value="nhn3" >
<input type="text" name="nhn1" value="nhn4" ><br/>
<input type="text" name="nhn1" value="nhn5" >
<input type="text" name="nhn1" value="nhn6" >
<input type="text" name="nhn1" value="nhn7" ><br/>
<input type="text" name="nhn1" value="nhn8" >
<input type="text" name="nhn1" value="nhn9" >
<input type="text" name="nhn1" value="nhn10" ><br/>
<input type="text" name="nhn1" value="nhn11" >
<input type="text" name="nhn1" value="nhn12" >
<input type="text" name="nhn1" value="nhn13" ><br/>
<input type="text" name="nhn1" value="nhn14" >
<input type="text" name="nhn1" value="nhn15" >
<input type="text" name="nhn1" value="nhn16" ><br/>
<input type="text" name="nhn1" value="nhn17" >
<input type="text" name="nhn1" value="nhn18" >
<input type="text" name="nhn1" value="nhn19" ><br/>
<input type="button" name="bbb" value="button" οnclick="test()" >
</form>
</BODY>
</HTML>
<script language="JavaScript" >
//给页面的文本元素加上监听器
var form=document.forms[0];
for(var i=0;i<form.length;i++){
if(form.elements[i].type=="text"){
oEventUtil.AddEventHandler(form.elements[i],'focus',oTF);
oEventUtil.AddEventHandler(form.elements[i],'blur',oTB);
}
}
</script>