DHtml attribute:onpropertychange

今天在设置textarea最大值的时候用上的,还算是比较好用的一种方法,share一下:

< SCRIPT  LANGUAGE ="JavaScript" >
<!--
function textCounter(field, maxlimit) 
    
if (field.value.length > maxlimit) 
        field.value 
= field.value.substring(0, maxlimit); 
}

//-->
</ SCRIPT >
< textarea  name =words  cols =73  rows =5  class =""  onPropertyChange ="textCounter(words,10)" ></ textarea >  

有一个问题就是如果用拖拉的方法往里面放文字的时候,会出现严重错误,还没有搞清楚是什么原因,希望有大虾能搞定

以下是事件的说明:

Fires when a property changes on the object.

Syntax

Inline HTML <ELEMENT onpropertychange = "handler" ... > All platforms
Event property object.onpropertychange = handler JScript only
object.onpropertychange = GetRef("handler") Visual Basic Scripting Edition (VBScript) 5.0 or later only
Named script <SCRIPT FOR = object EVENT = onpropertychange> Internet Explorer only

Event Information

Bubbles No
Cancels No
To invoke Cause a property to change value.
Default action Sends notification when a property changes.

Event Object Properties

Although event handlers in the DHTML Object Model do not receive parameters directly, a handler can query an event object for data.

Show Available Properties

altKey Sets or retrieves a value that indicates the state of the ALT key.
altLeft Sets or retrieves a value that indicates the state of the left ALT key.
ctrlLeft Sets or retrieves the state of the left CTRL key.
propertyName Sets or retrieves the name of the property that changes on the object.
shiftLeft Retrieves the state of the left SHIFT key.
srcElement Sets or retrieves the object that fired the event.
type Sets or retrieves the event name from the event object.

Remarks

The onpropertychange event fires when properties of an object, expando, or style sub-object change. To retrieve the name of the changed property, use the event object's propertyName property. This property returns a read-only string of the name of the property that has changed. In the case of Cascading Style Sheets (CSS) properties, the property name is prefixed with style. For example, if the CSS property pixelLeft is altered, the value of window.event.propertyName is style.left. By contrast, if the non-CSS property name is altered, the value of window.event.propertyName is name.

When the onpropertychange event fires, the srcElement property of the event object is set to the object whose property has changed.

Note  Changing the innerText or innerHTML of child elements will not cause the onpropertychange event to fire for the parent element.

你可能感兴趣的:(DHtml attribute:onpropertychange)