rem ' BBjHtmlView::executeScript
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(50,50,400,300,"executeScript",$00090083$)
window!.setCallback(window!.ON_CLOSE,"eoj")
html$ = "<html><head><style>p{margin:0;padding:0;}</style><title>BASIS</title></head>"
img$ = "https://www.basis.cloud/images/BusJGBetter.jpg"
html$ = html$ + "<body><img src="""+img$+""">"
url$ = "https://documentation.basis.cloud/BASISHelp/WebHelp/bbjobjects/Window/bbjhtmlview/bbjhtmlview.htm"
html$ = html$ + "<p>This is a <a href="""+url$+""">BBjHtmlView</a>."
html$ = html$ + "</body></html>"
htmlview! = window!.addHtmlView(101,25,25,350,150,html$,$$,switches$)
htmlview!.setCallback(htmlview!.ON_PAGE_LOADED,"page")
htmlview!.setCallback(htmlview!.ON_HYPERLINK_ENTER,"event")
htmlview!.setCallback(htmlview!.ON_HYPERLINK_EXIT,"event")
htmlview!.setCallback(htmlview!.ON_HYPERLINK_ACTIVATE,"event")
htmlview!.setCallback(htmlview!.ON_DROP_TARGET_DROP,"event")
htmlview!.setCallback(htmlview!.ON_GAINED_FOCUS,"event")
htmlview!.setCallback(htmlview!.ON_EXECUTE_SCRIPT,"event")
htmlview!.setCallback(htmlview!.ON_HTMLVIEW_DOWNLOAD,"event")
htmlview!.setCallback(htmlview!.ON_LOST_FOCUS,"event")
htmlview!.setCallback(htmlview!.ON_MOUSE_ENTER,"event")
htmlview!.setCallback(htmlview!.ON_MOUSE_EXIT,"event")
htmlview!.setCallback(htmlview!.ON_NATIVE_JAVASCRIPT,"event")
htmlview!.setCallback(htmlview!.ON_POPUP_REQUEST,"event")
htmlview!.setCallback(htmlview!.ON_RIGHT_MOUSE_DOWN,"event")
htmlview!.setCallback(htmlview!.ON_SCRIPT_LOADED,"event")
htmlview!.setCallback(htmlview!.ON_SCRIPT_FAILED,"event")
executeScript! = window!.addButton(1,25,200,350,25,"BBjHtmlView::executeScript samples",$$)
executeScript!.setCallback(BBjButton.ON_BUTTON_PUSH,"executeScript")
backgroundColor! = window!.addButton(2,25,240,350,25,"BBjHtmlView::executeScript backgroundColor",$$)
backgroundColor!.setCallback(BBjButton.ON_BUTTON_PUSH,"backgroundColor")
status! = window!.addStatusBar(99)
process_events
eoj:
release
page:
gosub event
return
event:
event! = sysgui!.getLastEvent()
event$ = event!.getEventName()
event$ = event$ + " " + event!.getUrl(err=*next)
print event$
status!.setText(event$)
System.out.println(event$)
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 info(3,6)="5" or info(3,6)="6" then js$ = "style.backgroundColor = """+rgb$+""""
print js$
status!.setText(js$)
print "executeScript ",js$," returns ",htmlview!.executeScript(js$)
htmlview!.executeScript("testjs('"+js$+"')")
return
executeScript:
gosub event
if info(3,6)="5" or info(3,6)="6" then body$ = "" else body$ = "document.body."
info$ = ""
js$ = body$ + "style.backgroundColor = ""#ffff00"""; gosub js
js$ = "Math.PI"; gosub js
js$ = "Math.sqrt(100)"; gosub js
js$ = "Math.sqrt(-1)"; gosub js
js$ = "document.hasFocus()"; gosub js
js$ = body$ + "style.backgroundColor"; gosub js
js$ = "undefined"; gosub js
js$ = "1/0"; gosub js
js$ = "-1/0"; gosub js
js$ = "'The quick brown fox jumps over the lazy dog.'.split(' ')"; gosub js
js$ = "(function(){var map = new Map(); map.set('a', 1); map.set('b', 2); map.set('c', 3); return map;})();"; gosub js
i = msgbox(info$,0,"BBjHtmlView::executeScript")
return
js:
info$ = info$ + "executeScript: "+js$ + $0a$
js! = htmlview!.executeScript(js$,1)
if js! = null() then
info$ = info$ + "result: null"
else
info$ = info$ + "result: " + js!.getClass().getName()+" = "+js!.toString()
endif
info$ = info$ + $0a0a$
return
|