BBjExecuteScriptEvent::getScript

Description

In BBj 19.10 and higher, this method returns the original script string passed to BBjHtmlView::executeAsyncScript(String script).

Syntax

Return Value

Method

String

getScript()

Parameters

None.

Return Value

Returns the original script string passed to BBjHtmlView::executeAsyncScript(String script).

Remarks

None.

Example

rem ' BBjHtmlView::executeAsyncScript
bui = info(3,6)="5"
client = 0
if info(3,6)<>"5" then
   client = msgbox("BBjHtmlView Client",7+32+512,"BBjHtmlView","Swing","JavaFX","Chromium")
   switch client
      case 1; rem ' Swing
         print stbl("!OPTIONS","CHROMIUM_HTMLVIEW=FALSE",ERR=*NEXT)
         print stbl("!OPTIONS","JAVAFX_HTMLVIEW=FALSE",ERR=*NEXT)
         break
      case 2; rem ' JavaFX
         print stbl("!OPTIONS","CHROMIUM_HTMLVIEW=FALSE",ERR=*NEXT)
         print stbl("!OPTIONS","JAVAFX_HTMLVIEW=TRUE",ERR=*NEXT)
         break
      case 3; rem ' Chromium
         print stbl("!OPTIONS","CHROMIUM_HTMLVIEW=TRUE",ERR=*NEXT)
         print stbl("!OPTIONS","JAVAFX_HTMLVIEW=TRUE",ERR=*NEXT)
         break
   swend
endif
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(50,50,300,400,"executeAsyncScript",$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
gosub makehtml
htmlview! = window!.addHtmlView(101,25,25,250,150,html$)
htmlview!.setCallback(htmlview!.ON_PAGE_LOADED,"pageloaded")
if bui then
   htmlview!.injectScript("function doAlert() { console.log(alert('Alert dialog')); }",1)
   htmlview!.injectScript("function doConfirm() { console.log(confirm('Confirm dialog')); }",1)
   htmlview!.injectScript("function doPrompt() { console.log(prompt('Prompt dialog')); }",1)
endif
print "getClientType: ",htmlview!.getClientType(err=*next)
print "getClientVersion: ",htmlview!.getClientVersion(err=*next)
alert! = window!.addButton(102,25,200,250,25,"alert",$$)
alert!.setCallback(alert!.ON_BUTTON_PUSH,"alert")
confirm! = window!.addButton(103,25,250,250,25,"confirm",$$)
confirm!.setCallback(alert!.ON_BUTTON_PUSH,"confirm")
prompt! = window!.addButton(104,25,300,250,25,"prompt",$$)
prompt!.setCallback(prompt!.ON_BUTTON_PUSH,"prompt")
backgroundColor! = window!.addButton(105,25,350,250,25,"backgroundColor",$$)
backgroundColor!.setCallback(backgroundColor!.ON_BUTTON_PUSH,"backgroundColor")
process_events
eoj:
release
makehtml:
html$ = ""
html$ = html$ + "<!DOCTYPE html> <html> <body>"
html$ = html$ + "<br><button onclick='doAlert()'>Alert</button>"
html$ = html$ + "<br><button onclick='doConfirm()'>Confirm</button>"
html$ = html$ + "<br><button onclick='doPrompt()'>Prompt</button>"
html$ = html$ + "<script>"
html$ = html$ + "function doAlert() { console.log(alert('Alert dialog')); }"
html$ = html$ + "function doConfirm() { console.log(confirm('Confirm dialog')); }"
html$ = html$ + "function doPrompt() { console.log(prompt('Prompt dialog')); }"
html$ = html$ + "</script>"
html$ = html$ + "</body> </html>"
return
pageloaded:
print sysgui!.getLastEvent()
htmlview!.setCallback(htmlview!.ON_EXECUTE_SCRIPT,"executeScript")
return
alert:
js$ = "alert('alert')"
gosub executeAsyncScript
return
confirm:
js$ = "confirm('confirm')"
gosub executeAsyncScript
return
prompt:
js$ = "prompt('prompt')"
gosub executeAsyncScript
return
executeScript:
event! = sysgui!.getLastEvent()
print event!.getEventName()," ",date(0:"%Hz:%mz:%sz.%tz %p")
print event!.getScript(),": ",event!.getResult()
return
backgroundColor:
r = rnd(255)
g = rnd(255)
b = rnd(255)
rgb$ = "#"+hta(chr(r))+hta(chr(g))+hta(chr(b))
js$ = "document.body.style.backgroundColor = """+rgb$+""""
if bui then js$ = "style.backgroundColor = """+rgb$+""""
gosub executeAsyncScript
return
executeAsyncScript:
htmlview!.executeAsyncScript(js$)
print "executeAsyncScript ",date(0:"%Hz:%mz:%sz.%tz %p")," ",js$
return

See Also

BBjAPI

BBj Object Syntax

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



______________________________________________________________________________________

Copyright BASIS International Ltd. BBj®, Visual PRO/5®, PRO/5®, and BBx® are registered trademarks.