问题描述
网页源代码如下:<scripttype="text/javascript"src="../global/enroll/js/jquery-1.5.1.min.js"></script><scripttype="text/javascript"src="../global/enroll/js/vote.js"></script><scripttype="text/javascript"src="../global/enroll/js/validator/IDValidator.js"></script><scripttype="text/javascript"src="../global/enroll/js/voteValidation.js"></script><scripttype="text/javascript"src="../global/enroll/js/My97DatePicker/WdatePicker.js"></script><scripttype="text/javascript">varerror='';varmsg='';window.onload=function(){//如果选的是营销员显示营销员信息showTeacherMessage();//如果选中我有知道老师,显示教师信息,showSaleMessage();$("input[name='author.birthday']").blur(function(){varauthorBirthday=$("input[name='authorBirthday']").val();if(authorBirthday!=null&&authorBirthday!=""){$.ajax({type:"POST",//HTTP请求方式url:"../ageGroup/getAgeGroupByBirthday",//请求URLdataType:"json",async:true,//(默认:true)data:{'birthday':authorBirthday},//封装请求参数dataType:"JSON",success:function(data){$("li[name='birthDayLi']").show();if(data.flag){$("span[name='birthDayInfo']").html("作者年龄为:"+data.age+"周岁,属于"+data.ageGroup);}else{$("span[name='birthDayInfo']").html("对不起,此作者年龄不能参与报名。");}}});}//第一个作者生日失焦时间,获取计算年龄,判断nianl$("#authorBirthday0").blur(function(){vard=newDate();varnowYear=d.getFullYear();varnowMonth=d.getMonth()+1;varnowDay=d.getDate();varstrBirthdayArr=$(this).val().split("-");varbirthYear=strBirthdayArr[0];varbirthMonth=strBirthdayArr[1];varbirthDay=strBirthdayArr[2];varage=null;if(nowYear-birthYear<=0){age=nowYear-birthYear;}else{if(nowMonth-birthMonth<0){age=nowYear-birthYear-1;}elseif(nowMonth-birthMonth==0){if(nowDay-birthDay<0){age=nowYear-birthYear-1;}else{age=nowYear-birthYear;}}else{age=nowYear-birthYear;}}if(birthYear!=""&&birthYear!=null){$("#age").val(age+"岁");}else{$("#age").val("");$("#ageGroup").val("");}//根据年龄判断在哪个年龄组$.ajax({type:"POST",//HTTP请求方式url:"../dictionary/findAgegroupByAge",//请求URLdata:{'age':age},//封装请求参数success:function(data){$("#ageGroup").val(data);}});});});varauthorBirthday0=$("#authorBirthday0").val();if(authorBirthday0!=""&&authorBirthday0!=null){vard=newDate();varnowYear=d.getFullYear();varnowMonth=d.getMonth()+1;varnowDay=d.getDate();varstrBirthdayArr=$(this).val().split("-");varbirthYear=strBirthdayArr[0];varbirthMonth=strBirthdayArr[1];varbirthDay=strBirthdayArr[2];varage=null;if(nowYear-birthYear<=0){age=nowYear-birthYear;}else{if(nowMonth-birthMonth<0){age=nowYear-birthYear-1;}elseif(nowYear-birthYear==0){if(nowDay-birthDay<0){age=nowYear-birthYear-1;}else{age=nowYear-birthYear;}}else{age=nowYear-birthYear;}}if(birthYear!=""&&birthYear!=null){$("#age").val(age+"岁");}//根据年龄判断在哪个年龄组$.ajax({type:"POST",//HTTP请求方式url:"../dictionary/findAgegroupByAge",//请求URLdata:{'age':age},//封装请求参数success:function(data){$("#ageGroup").val(data);}});}else{$("#age").val("");$("#ageGroup").val("");}//}<li><spanclass="bdh_text_c">*出生日期:</span><inputname="author.birthday"type="text"class="bdh_wbk"id="authorBirthday0"value=""onclick="WdatePicker({minDate:'{%y-16}-{%M}-{%d}',maxDate:'{%y-3}}-{%M}-{%d}'});"/><spanstyle="color:#99cccc;margin-left:8px;">出生日期可手工录入,格式例如:1978-02-05</span></li><li><spanclass="bdh_text_c">*年龄:</span><inputname="age"type="text"class="bdh_wbk"readonly="readonly"id="age"maxlength="50"/></li><li><spanclass="bdh_text_c">*组别:</span><inputname="ageGroup1"type="text"class="bdh_wbk"readonly="readonly"id="ageGroup"maxlength="50"/></li>
解决方案
解决方案二:
据说可以向网页中注入代码,会编写代码,然后会注入就能捕捉失焦事件。
解决方案三:
可以换个失路,让网页中别的元素获得焦点呀,js:elemxxxx.focus();
解决方案四:
参考:使用RaiseEvent("onblur")
解决方案五:
在标签上加入onFocus和onblur或者在脚本中加入blurFocus失去焦点做什么获得焦点做什么(~o~)~zZ