Contents Index Topic Contents |
Using Default Interface Descriptions
If there is no Public_Description object defined in the scriptlet, the scriptlet container object exposes properties and methods using variables and functions in the scriptlet that follow certain naming conventions. To expose scriptlet properties and methods, use these conventions:
- Use the prefix
public_
to indicate that a variable or function should be exposed by the scriptlet.- To create a read/write property, declare a variable scoped at the page level (that is, not defined inside a function) and give it a
public_
prefix.- To create a method, define a function with the prefix
public_
.- To create a readable property as a function, define a function with the prefix
public_get_
.- To create a writable property as a function, define a function with the prefix
public_put_
.Note When a property or method is exposed, its name in the host application does not have the
public_
prefix. For example, if you define a property calledpublic_MyTitle
in the scriplet, its name in the host application isMyTitle
.The following table shows examples of variables and functions in a scriptlet, and the resulting interface that they expose in the host application.
Example Exposed As Used in container var public_Color = "red"Property vColor = SC1.Color SC1.Color = "blue" function public_look(param)Method SC1.look(param) function public_get_C()Property (read) x = SC1.C function public_put_C(param)Property (write) SC1.C = "test" function look()Not available
(nopublic_
prefix) function get_C()Not available
(nopublic_
prefix) var Color = red;Not available
(nopublic_
prefix) var get_Color = red;Not available
(nopublic_
prefix)
For example, the following example shows a portion of a page containing a paragraph named "P1." The script block following the paragraph exposes a property called
P1Text
and a method calledSetText
.<P ID=P1>This is a paragraph of text.</P> <SCRIPT LANGUAGE="JavaScript"> <!-- public_P1Text = P1.innerText function public_SetText(newText){ P1.innerText = newText; } // --> </SCRIPT>The scriptlet reserves the function name prefixes
public_get_
andpublic_put_
to define properties. For example, if the scriptlet contains a function namedpublic_get_MyText
, it will be treated as a property calledMyText
. If you attempt to call the functionpublic_get_MyText
as a method using the syntaxSC1.get_MyText()
, an error will result, because the function itself is exposed only as if it were a property namedMyText
.See Also
Creating a Public_Description Object
Adding Scriptlets to Your Application
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.