rem ' BBjHtmlView::injectURL
bui = info(3,6)="5"
client = 0
if info(3,6)<>"5" and info(3,6)<>"6" 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
js$ = "https://www.poweredbybbj.com/files/scripts/hello.js"
bad$ = "https://www.poweredbybbj.com/files/scripts/oops.js"
injectUrl = msgbox("injectUrl Good or Bad JavaScript?",7+32+512,"injectUrl","Good","Bad")
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(50,50,300,250,"injectUrl",$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
html$ = "<html>"
html$ = html$+"<body>"
html$ = html$+"<input type='button' onclick='hello()' value='Click Me!' style='margin:15px;'>"
rem html$ = html$+"<script src="+js$+"></script>"
html$ = html$+"</body></html>"
htmlview! = window!.addHtmlView(101,25,25,250,150,html$)
htmlview!.setCallback(htmlview!.ON_PAGE_LOADED,"page")
htmlview!.setCallback(htmlview!.ON_SCRIPT_LOADED,"loaded")
htmlview!.setCallback(htmlview!.ON_SCRIPT_FAILED,"failed")
htmlview!.setCallback(htmlview!.ON_EXECUTE_SCRIPT,"script")
print date(0:"%Hz:%mz:%sz.%tz %p ") + htmlview!.getClientType()," ",htmlview!.getClientVersion()
button! = window!.addButton(1,25,200,250,25,"Click Me!",$$)
button!.setCallback(button!.ON_BUTTON_PUSH,"click")
process_events
eoj:
release
page:
event! = sysgui!.getLastEvent()
print date(0:"%Hz:%mz:%sz.%tz %p "),event!.getEventName()," ",event!.getUrl()
htmlview!.clearCallback(htmlview!.ON_PAGE_LOADED)
if injectUrl = 1 then
htmlview!.injectUrl(js$,bui)
else
htmlview!.injectUrl(bad$,bui)
endif
return
loaded:
event! = sysgui!.getLastEvent()
print date(0:"%Hz:%mz:%sz.%tz %p "),event!.getEventName()," ",event!.getUrl()
gosub click; rem ' this works because we waited until the script was loaded
return
failed:
event! = sysgui!.getLastEvent()
print date(0:"%Hz:%mz:%sz.%tz %p "),event!.getEventName()," ",event!.getUrl()
return
click:
wnd$ = iff(bui,"$wnd.","window.")
htmlview!.executeScript(wnd$+"hello()")
return
script:
event! = sysgui!.getLastEvent()
print date(0:"%Hz:%mz:%sz.%tz %p "),event!.getEventName()," ",
print event!.getScript(),": ",event!.getResult()
return
|