spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column22


Scriptlet Authoring

Developer News
HP to Microsoft: Thanks for Nothing
iPhone Remains Left Out as Android Scores Flash
The Year of Living the OpenSocial

A scriptlet is an independent script that is referenced from an HTML page. It represents an object that accepts data from the outside and supports several operations on this data. A scriptlet describes the behavior of an object and the event it is triggered by. A scriptlet also allows you to define new events. Scriptlets are supported by Internet Explorer 4.0 and up and are not supported by Netscape Navigator. Internet Explorer 5.0 added the support for Behaviors to scriptlets. A scriptlet resides in a file of its own, with extension .sct. A scriptlet file opens with a <SCRIPTLET> tag and closes with a </SCRIPTLET> tag:


<SCRIPTLET>......</SCRIPTLET>

A scriptlet is divided into two parts: the interface definition section and the internal implementation section. The interface definition section includes IMPLEMENTS tags. Each IMPLEMENTS tag opens with <IMPLEMENTS> and closes with </IMPLEMENTS>. There are two types of <IMPLEMENTS> tags: <Behavior> and <Automation>. The <Behavior type specifies the event associated with the Behavior, such as the following:


<IMPLEMENTS ID="kuku" TYPE="Behavior" DEFAULT>
<EVENT NAME="onFifthBlink"/>
</IMPLEMENTS>

The Automation type of the <IMPLEMENTS> tag specifies the scriptlet's object interface parameters and supported methods:


<IMPLEMENTS TYPE="Automation">
<METHOD NAME="blink"/>
<PROPERTY NAME="x"/>
<PROPERTY NAME="y"/>
</IMPLEMENTS>

The internal implementation section consists of a JavaScript script. This script implements the internal details of the object's methods. As seen above, only one method is defined, the blink() function. Here is the whole internal implementation section:


<SCRIPT LANGUAGE="JavaScript">
var msecs =2000;
var counter = 0;
style.position = "absolute";
style.pixelTop = x;
style.pixelLeft = y;
window.attachEvent("onload", onload);
function onload(){
  window.setTimeout(uniqueID+".blink()", msecs);
}
function blink() {
  style.visibility = (style.visibility == "hidden") ? "visible" : "hidden";
  counter +=1;
  if (counter == 10) {
    fireEvent("onFifthBlink");
    counter = 0;
  }
  window.setTimeout(uniqueID+".blink()", msecs);
}
</SCRIPT>

The following pages cover each of the above sections in more details.

http://www.internet.com

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script · Book Review: Content Rich
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Building Command Line Utilities with Python · fring Brings Mobility to Junction Networks' OnSIP · Another Big Win for Wi-Fi Positioning


Created: July 19, 1998
Revised: July 19, 1998

URL: http://www.webreference.com/js/column22/emulate.html