Web Add-in Extensibility Developer Guide > Web Add-in Extensibility API reference > Mercury.QTP.ToolkitManager Namespace > _util Class > _util Class Methods > Alert Method

_util.Alert Method

Opens a modal message box displaying the specified message.

Remarks

In the following situations, the message box is not displayed:

  • When your support runs on a browser with protected mode ON
  • When your support runs on Internet Explorer 9

Syntax

JScript 
public function Alert( 
   message : String
);

Parameters

message
The message to display.

Example

The following JavaScript function selects a specified book in a WebExtUsedBooks object. Before attempting to select the book, the function checks the validity of the specified index. If the index is out of range, the SelectBook function calls the _util.Alert method to display an error message box in the browser, in addition to throwing an exception to cause the test to fail.

function SelectBook( BookIndex )
// Select the radio button for the specified index and click the "Select" link.
{
  if( BookIndex > BookCount() )
  {
     // Display an error message in Internet Explorer.
     _util.Alert("Book index '" + BookIndex + "' is out of range !")
     // Fail the step and cause UFT to display a run-time error.
     throw "Book index is out of range !"
  }

  // Select the radio button corresponding to the specified index.
  GetTableElem().rows[1+BookIndex].cells[0].children[0].click();
  // Wait a while to enable users to see that the correct radio button is selected.
  _util.Wait(1000);
  // Click the "Select" link (the 3rd child of the DIV element).
  _elem.children[2].click();
  _util.LogLine("Running SelectBook test object method.",1);
}