标题 | onpropertychange |
范文 | 经常看到网上或者在写代码的时候写到onchange事件,也有个onpropertychange事件,onpropertychange是指属性的变化事件. 比如:<select onchange=""></select> 当发生变化时触发onchange事件,是指鼠标和键盘事件结束才能触发 假如 是<input type="text" onchange="">也只有当焦点离开文本框并且文本框值发生变化才触发 而onpropertychange表示对象的属性,包括任何值,比如type,value等,只要发生变化即可触发,onpropertychange事件.举例说明: <html> <head> <meta http-equiv="content-Type" content="text/html;charset=gb2312"> <title>js 只能输入数字和小数点</title> <script language="JavaScript" type="text/javascript"> function forasp_cn(obj) { alert(obj); } function forasp_cn2(obj) { alert("触发onpropertychange事件"); } </script> </head> <body> 输入onpropertychange测试:<input id="input1" onchange="forasp_cn(this.value);" onpropertychange="forasp_cn2();"> </body> </html> onpropertychange一般用于图像上传前的判断大小,详细情况: <script> function chkimg(Obj){ var tempImg=new Image(); tempImg.onerror=function(){alert('目标类型错误或路径不存在!');Obj.outerHTML=Obj.outerHTML;}; tempImg.onload=function(){if(this.width>91 || this.height>81) {alert('超出规定尺寸!');Obj.outerHTML=Obj.outerHTML;}}; tempImg.src=Obj.value; } </script> <html> <input name="upfile" type="file" size="50" onpropertychange=chkimg(this)> </html> 这就是对onpropertychange 的解释 |
随便看 |
|
在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。