BUI logoDWC logoBBjWebManager::injectStyleUrl

Description

In BBj 22.03 and higher, this method injects the specified external CSS URL into the web page. External CSS is injected asynchronously; success or failure is reported with BBjLinkLoadedEvent or BBjLinkFailedEvent.

Note:

In BBj 22.03 and higher, BBjWebManager is an alias for BBjBuiManager.

Syntax

Return Value Method

void

injectStyleUrl(String url)
void injectStyleUrl(String url, boolean top)
void injectStyleUrl(String url, boolean top, String attributes)

void

injectStyleUrl(String url, boolean top, HashMap attributes)

Parameters

Parameter Description
url A CSS URL to be injected into this web page as a style element.
top A boolean value specifying whether this style is to be injected into the top level window of the page.
attributes A set of attributes to be added to the style element. Attributes can be specified either as a string in the format "attr=value,attr=value" or as a HashMap containing key/value pairs.

Return Value

None.

Example

rem ' BBjWebManager::injectStyleUrl

url$ = "https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css"
top = 1
attributes$ = ""

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()

title$ = "BBjWebManager::injectStyleUrl"
window! = sysgui!.addWindow(25,25,600,225,title$,$00090083$)
window!.setCallback(window!.ON_RESIZE,"resize")
window!.setCallback(window!.ON_CLOSE,"eoj")

window!.addStaticText(101,5,25,90,25,"URL:",$8000$)
url! = window!.addEditBox(102,100,25,475,25,url$,$$)

top! = window!.addCheckBox(103,100,75,475,25,"Top",$$)
top!.setSelected(top)

window!.addStaticText(104,5,125,90,25,"Attributes:",$8000$)
attributes! = window!.addEditBox(105,100,125,475,25,attributes$,$$)

injectStyleUrl! = window!.addButton(1,100,175,475,25,"injectStyleUrl",$$)
injectStyleUrl!.setCallback(injectStyleUrl!.ON_BUTTON_PUSH,"injectStyleUrl")

browser! = bbjapi().getWebManager(err=oops)
browser!.setCallback(browser!.ON_LINK_LOADED,"loaded")
browser!.setCallback(browser!.ON_LINK_FAILED,"failed")

process_events

oops:
i = msgbox("This functionality is only supported in browser environments.")

eoj:
release

resize:
    event! = sysgui!.getLastEvent()
    width = event!.getWidth()
    height = event!.getHeight()
    url!.setSize(width-125,25)
    top!.setSize(width-125,25)
    attributes!.setSize(width-125,25)
    injectStyleUrl!.setSize(width-125,25)
return

injectStyleUrl:
    url$ = url!.getText()
    top = top!.isSelected()
    attributes$ = attributes!.getText()
    browser!.injectStyleUrl(url$, top, attributes$)
return

loaded:
    event! = sysgui!.getLastEvent()
    msg$ = date(0:"%Hz:%mz:%sz.%tz %p ")+event!.getEventName()+" url="+str(event!.getUrl())
    i = msgbox(msg$)
return

failed:
    event! = sysgui!.getLastEvent()
    msg$ = date(0:"%Hz:%mz:%sz.%tz %p ")+event!.getEventName()+" url="+str(event!.getUrl())
    i = msgbox(msg$)
return

See Also

BBjAPI

BBjSysGui

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