HTC Basics

HTC is the abbreviation of HTML Component, which is a client-side component supported by IE5 and later browsers. As far as I understand it, HTC is a set of scripts that encapsulate client-side behavior based on DHTML. Each HTC is stored in a *.htc file, and an HTC is a client-side "class".  
The object 
     document represents the HTML document in the given browser window. 
     element returns a reference to the tag of the link behavior in the main document. 
     PUBLIC:ATTACH binds a function to an event, so that the function is called each time the event occurs on a particular object. 
     PUBLIC:COMPONENT specifies the contents of the file in HTC. 
     PUBLIC:DEFAULTS Sets a copy of HTC's default properties. 
     PUBLIC:EVENT Defines an HTC event to expose to the document containing the HTC. 
     PUBLIC:METHOD Defines an HTC method to expose to the document containing the HTC. 
     PUBLIC:PROPERTY Defines an HTC property that is exposed to documents containing the HTC.  
The method 
     createEventObject 
     creates an event object and is used when additional information about the event needs to be passed to the fire method of the PUBLIC:EVENT element. 
event 
     oncontentready Occurs 
     when the content of the element to which the behavior is attached has been fully parsed. 
     oncontentsave 
     concatenates an element behavior that occurs before an element's content is saved or copied. 
     ondetach Occurs before disconnecting  an action
     from an element. 
     ondocumentready 
     occurs when the document containing the behavior has been fully parsed. 

Example

Copy the code The code is as follows:


METHOD NAME="select"/><!--Select all. Since the reference edit box is composed of INPUT and IMG, it is necessary to rewrite (overload) the select method--> <PUBLIC:METHOD NAME="focus"><!-- to set the focus. Since the reference edit box is composed of INPUT and IMG, it is necessary to rewrite (overload) the focus method --> 













<PUBLIC:PROPERTY NAME="input" GET="getInput"/> 
<PUBLIC:PROPERTY NAME="value" GET="getValue" PUT="setValue"/> 
<PUBLIC:METHOD NAME="cellDataCheck"/> 
</ PUBLIC:COMPONENT> 
<script language="javascript">     
    var id = null; 

    //The reference generally has two values, one is the displayed Text and the other is the id. idColumn specifies the Grid column of the id 
    var idColumn = null; 

    var refUrl = null; 
    var refIdColumn = null; 
    var refNameColumn = null; 

    var extendedProp = element.extendedProperties; 
    if(extendedProp!= null && typeof(extendedProp) != "undefined") 
    { 
        var dom = new ActiveXObject("MSXML. 


        idColumn = dom.documentElement.getAttribute("idColumn"); 

        var refInfo = dom.documentElement.firstChild; 
        refIdColumn = refInfo.getAttribute("idColumn"); 
        refNameColumn = refInfo.getAttribute("nameColumn"); 
        refUrl = refInfo.getAttribute("url"); 
    } 

    var btn = element.getElementsByTagName("IMG")[0];     
    btn.onclick = btnClick; 
    function btnClick() 
    { 
        var ret = window.showModalDialog(refUrl,self,'scrolling:no;resizable:no;status:no;dialogWidth:550px;dialogHeight:450px;center:1'); 

        if(ret != null) 
        { 
            var el = ret.documentElement.firstChild; 
            if(el != null) 
            { 
                input.value = el.getAttribute(refNameColumn); 

                if(idColumn != null && idColumn!="") 
                { 
                    id = el.getAttribute(refIdColumn); 
                    grid.setCellValue(grid.row,idColumn,id); 
                }             
            } 
        } 

        //-------------------------------------------------------------- 
        grid.setCellValue(grid.row,"num",100); //赋值示例 
        grid.setCellValue(grid.row,"price",10);//Assignment example      var statusText = "";          } 
        //-------------------------------------------- ----------------- 



    var input = element.getElementsByTagName("INPUT")[0]; 
    input.onblur = inputOnBlur; 

    function inputOnBlur() 
    { 
        grid.status = statusText; //You can use grid.status to modify the status of the Grid status bar. 
    } 

    function getInput() 
    { 
        return input; 
    }     

    //This method is called by SmartGrid when the editor is displayed. Since the reference editor is composed of elements such as INPUT and IMG, it is necessary to tell SmartGrid which element should get the focus when setting the editor focus! 
    function focus() 
    {     
        input.focus();     
    } 

    //This method is called by SmartGrid when all editors are selected. Since the reference editor is composed of elements such as INPUT and IMG, it is necessary to tell SmartGrid how to select all the content of the editor when it is selected! 
    function select() 
    { 
        input.select(); 
    } 

    function setValue(val) 
    { 
        input.value = val; 

        if(idColumn != null) 
        { 
            var r = grid.row; 
            id = grid.getCellValue(r,idColumn); 
        } 
    } 

    function getValue() 
    { 

        return input.value ; 
    } 

    function cellDataCheck(args) 
    { 
        return ;     
    } 

</script> 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325686633&siteId=291194637