zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    C#进阶系列——WebApi 路由机制剖析:你准备好了吗?
    Socket长连接和短连接的区别
    C#socket通信时,怎样判断socket双方是否断开连接
    Redis常见面试题
    [C# 线程处理系列]专题三:线程池中的I/O线程
    结对编程第一次作业
    软件工程第三次作业
    软件工程第二次作业
    人生中的第一篇博客
    CPU 分类
  • 原文地址:https://www.cnblogs.com/rickel/p/168683.html
Copyright © 2011-2022 走看看