BUI logoDWC logoBBjWebManager::executeScript

Description

In BBj 22.14 and higher, this method executes the specified JavaScript in this web page. This is equivalent to BBjSysGui::executeScript.

Note:

In BBj 22.03 and higher, BBjWebManager is an alias for BBjBuiManager.

Syntax

Return Value Method
Object executeScript(String script)
Object executeScript(String script, boolean await)

Parameters

Parameter Description
script JavaScript to be executed in this BBjHtmlView.
await In BBj 23.04 and higher, this optional boolean value specifies that the DWC client should execute this script using the JavaScript await operator. If not specified, the default is false (0).

Return Value

This method returns the execution result, converted from JavaScript to the closest Java equivalent. If the return value is a JavaScript type that can't be represented as a Java type, a simple String representation is returned.

Example

rem ' BBjWebManager::executeScript

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(50,50,300,200,"executeScript",$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
executeScript! = window!.addButton(1,25,25,250,25,"executeScript")
executeScript!.setCallback(executeScript!.ON_BUTTON_PUSH,"executeScript")
js! = window!.addStaticText(101,25,75,250,100,"",$$)
status! = window!.addStatusBar(99)
script$ = "function testjs(parameter1){alert('testjs: '+parameter1);return 'invoked testjs function'}"
web! = bbjapi().getWebManager()
web!.injectScript(script$,1)
bui = info(3,6)="5"
dwc = info(3,6)="6"
doc$ = iff(bui,"$doc","document")
wnd$ = iff(bui,"$wnd","window")
process_events

eoj:
release
return

executeScript:
    r = rnd(255)
    g = rnd(255)
    b = rnd(255)
    rgb$ = "#"+hta(chr(r))+hta(chr(g))+hta(chr(b))
    js$ = doc$+".body.style.backgroundColor = """+rgb$+""""
    status!.setText(js$)
    js!.setText(js$)
    result! = web!.executeScript(js$)
    i = msgbox(js$,0,str(result!))
    js$ = wnd$+".testjs('"+js$+"')"
    result! = web!.executeScript(js$)
    i = msgbox(js$,0,str(result!))
return

ClosedVersion History

  • BBj 23.04: Added an optional await argument.
  • BBj 22.14: BBjWebManager::executeScript added.

See Also

BBjAPI

BBjSysGui

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.