Common JavaScript Global Methods

Public Methods

 NameDescription
Public MethodgetFrameElement Method Returns the frame element that contains the current element.  
Public MethodtoSafeArray Method Converts a JavaScript Array object to COM SafeArray.  
Public Methodtrim Method Returns the string after stripping leading and trailing white spaces.  

getFrameElement Method

Returns the frame element that contains the current element.

Remarks

This function operates on the element represented by the _elem token. When an element is being learned, _elem represents that element. In an event handler, _elem is the root element of the control you are supporting.

Syntax

JScript

public function getFrameElement( );

Returns

The containing frame element if found. Otherwise, null.

toSafeArray Method

Converts a JavaScript Array object to a COM SafeArray.

Remarks

Some UFT utility methods, such as Record and Report, require SafeArray type arguments.

Syntax

JScript

public function toSafeArray(

inArray : Array

);

Parameters

inArray. A JavaScript Array.

Returns

A SafeArray with the elements of the input array in the same order.

Example

In the following example, an array is created, and then converted to a SafeArray.

var arr = new Array();

// Add objects to the array.

arr[0] = "item1";

arr[1] = "item2";

arr[4] = "item3";

// Return a COM array with the following items:

// { "item1", "item2", null, null, "item3" }

return toSafeArray(arr);

trim Method

Strips leading and trailing white spaces from a string.

Syntax

JScript

public function trim(

inString : String

);

Parameters

inString. The string to trim.

Returns

The input string after stripping leading and trailing white spaces.

See also: