BBjHtmlView::injectUrl

Description

In BBj 17.0 and higher, this method injects the specified JavaScript URL into the HTML document of this BBjHtmlView control, making it available for subsequent use by BBjHtmlView::executeScript.

Syntax

Return Value

Method

void

injectUrl(string url)

void

injectUrl(string url, boolean top)

Parameters

Return Value

Method

url

URL containing JavaScript  to be injected into the HTML document of  this BBjHtmlView.

top

Boolean value specifying whether this URL is to be injected into the top level window of the page.

Return Value

None.

Remarks

None.

Example

rem ' BBjHtmlView::injectURL
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,250,"injectUrl",$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
js$ = "https://www.poweredbybbj.com/files/scripts/hello.js"
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,"inject")
button! = window!.addButton(1,25,200,250,25,"Click Me!",$$)
button!.setCallback(button!.ON_BUTTON_PUSH,"click")
process_events
eoj:
release
inject:
htmlview!.injectUrl(js$,1)
htmlview!.clearCallback(htmlview!.ON_PAGE_LOADED)
return
click:
htmlview!.executeScript("hello()")
return

Contents of https://www.poweredbybbj.com/files/scripts/hello.js

function hello() {
alert("Hello from an external JavaScript file")
}

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

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.