BUI 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)

Parameters

Variable Description
script JavaScript to be executed in this web page.

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.

Remarks

None.

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

See Also

BBjAPI

BBjSysGui

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