网站制作学习网JS脚本→正文:onpropertychange
字体:

onpropertychange

JS脚本 2010/6/10 14:43:29  点击:不统计

http://www.forasp.cn/

经常看到网上或者在写代码的时候写到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" style="width:200;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff" onpropertychange=chkimg(this)>
</html>
这就是对onpropertychange 的解释


网站http://www.制forasp作.cn

·上一篇:仿163注册提示 >>    ·下一篇:javascript颜色器 >>
推荐文章
最新文章