BrowserCloseWindow Function

Action

Closes the window (tab) that is currently active in the web browser, or a window specified by a handle.

注: The first window opened (the main window) cannot be closed.

Include file

BrowserAPI.bdh

Syntax

BrowserCloseWindow( uHandle : in number optional ): boolean;
Parameter Description
uHandle Optional: The handle returned by a previous BrowserGetActiveWindow call. If not specified, the active window is closed.

Return value

  • true if successful

  • false otherwise

Example

benchmark SilkPerformerRecorder

use "Kernel.bdh"
use "BrowserAPI.bdh"

dcluser
  user
    VUser
  transactions
    TInit           : begin;
    TMain           : 1;

var

dclrand

dcltrans
  transaction TInit
  begin
  end TInit;

  transaction TMain
  var
    wnd1   : number;
    wnd2   : number;
    check1 : number;
  begin
    BrowserStart(BROWSER_MODE_DEFAULT, 800, 600);    
    BrowserNavigate("http://demo.borland.com/TestSite/multiplewindows/multipleWindows.html");
    wnd1 := BrowserGetActiveWindow("mainWindow");
    BrowserLinkSelect("//A[@name='window1']",  "Select, BODY (#1)");
    wnd2 := BrowserGetActiveWindow("first window");
    BrowserActivateWindow(wnd1);
    BrowserLinkSelect("//A[@name='window2']",  "Select, BODY (#1)");
    
    BrowserCloseWindow(wnd2); // close second window (tab)
    BrowserCloseWindow();     // close active window (tab)
  end TMain;