Neatware Header
Home   Products   Forums   Partners   Buy   Company   Contact   Blog   

Script

Scripts are programs that embed in a HTML document. Scripts may modify the document dynamically, response events such as mouse moving, and generate GUI. One kind of script executes one time when a document is loaded. Another kind of script is triggered whenever a specific event occurs.

  1. Script
  2. _script command defines a script in its content. It maybe nested and appeared any times. 'type' and 'src' attribute specify the scripting language (e.g. text/javascript) and the location of an external script respectively.

    _script "type='text/javascript'"
      # ... JavaScript
    script_        
    
  3. Event

    Intrinsic events will active script to execute. There are many events for client interactive controls.

    onload
    it occures after loading a frame or window. used in _frameset or _body.
    onunload
    it occures when a browser removes a doc. used in _frameset or _body.
    onclick
    it occures when mouse is clicked over an element.
    ondbclick
    it occures when mouse is double clicked over an element.
    onmousedown
    it occures when mouse button is pressed on an element.
    onmouseup
    it occures when mouse button is released over an element.
    onmouseover
    it occures when mouse moved onto an element.
    onmousemove
    it occures when mouse moved while it is over an element.
    onmouseout
    it occures when mouse moved away from an element.
    onkeypress
    it occures when a key is pressed and released over an element.
    onkeydown
    it occures when a key is pressed down over an element.
    onkeyup
    it occures when a key is released over an element.
    onfocus
    it occures when an element receives focus. used with _label, _input, _select, _textarea, and _button commands.
    onblur
    it occures when an element loses focus. used like 'onfocus'.
    onsubmit
    it occures when a form is submitted. used with _form.
    onreset
    it occures when a form is reseted. used with _form.
    onselect
    it occures when user selects a text clip in a text field. used with _input and _textarea.
    onchange
    it occures when a control loses the input focus and its value has been modified _input, _select, or _textarea.
  4. Activation

    The intrinsic event has a value of script. An event actives the executation of a script. Script's syntax is dependent on the scripting language. Except the Javascript and VB Script, Snaml is also suitable to write a script.

    The _noscript command provides alternate content when a script is not executed. A better practice is adding _comment command in the script content. A browser that does not recognize the scripting language will ignore them.

    _input "name='edit1' size='32'"
    _script "type='text/Snaml'"
      _comment
      proc edit1_changed {} {
        if {[edit value] == "Snaml"} {
          button1 enable 1
        } else {
          button1 enable 0
        }
      }
      edit1 onChange edit1_changed
      comment_
    script_