安排不好程序,要求给输入框内容赋值时触发事件
可以用onpropertychange来实现的。
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head>

<body>
<input id=i>
</body>
<script language="javascript">
<!--
i.onchange = function(){
if(i.old == i.value){
alert('not change')
}else{
i.old = i.value
alert('changed')
}
}

i.value = 'abc'
i.onchange()
i.value = 'abc'
i.onchange()
i.value = 'def'
i.onchange()

function Value(v){
if(this.old == v){
alert('not change')
}else{
this.old = this.value
this.value = v
this.onchange()
}
}

i.Value = Value

i.Value('abc')
i.Value('abc')
i.Value('def')
//-->
</script>
</html>
没














































