Author's note: There was no response when I used the onchange event today. Finally, I checked the information and found out about the limitations and instability of Onchange. But onpropertychange can be implemented very well, especially its real-time capture performance, which is worth using (Thanks to this performance, the boss lady is very satisfied with what I made o(∩_∩)o...).
I am also quite lazy, and I am too lazy to sort out the things I have made, so I can only share the original version of the information I searched for:
Under IE, when the properties of an HTML element change, it can be captured through onpropertychange. For example a
<input name="text1" id="text1" />
When the value attribute of the object is modified by the script of the page, onchange cannot capture it, but onpropertychange can capture it. (Captured in real time)
In other words: onpropertychange can capture changes in attribute values in a timely manner, and onchange must cause the current element to lose focus (onblur) when the attribute value changes to activate the event!
like:
Example 1:
Please enter the image address: <input type="text" name="mytext" size="10" value="" onpropertychange="document.images['myimg'].src=this.value;" /> <img id ="myimg" src="/img/common/logo.gif" />
When the content in the text box is changed, the picture will be displayed immediately. And if you use onchange, when changing its value, you need to click on a blank space or other place with the mouse to make the input element lose focus (onblur) to activate the event and the image display will be changed!
Example 2:
<INPUT id="image" style="WIDTH: 448px; HEIGHT: 22px" onpropertychange="preview.src=image.value" type="file" size="55" name="File1" runat="server">
<IMG id="preview" src="">
-------------------------------------------------- ---------------
The onpropertychange event is so cute, I fell in love with it at first sight
onChange: An event triggered when the current element loses focus and the content of the element changes [can be triggered by both mouse and keyboard]
Therefore, when the value of the object is changed by the script, the onChange event will not be triggered because the user neither moves the mouse nor the keyboard.