BUI logoDWC logoBBjWebManager::setStyle

Description

In BBj 23.00 and higher, this method sets a CSS style on one or more elements on the web page.

Note:

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

Syntax

Return Value Method
void setStyle(String property, String value)
void setStyle(String property, String value, String selector)

Parameters

Parameter Description
property Specifies the CSS property to be set on the web page.
value Specifies the value of that CSS property.
selector By default, setStyle applies to the document element on the web page. If a selector is specified, it selects one or more descendant elements within the document to set this CSS property. If a specified selector doesn't return any elements, the document element is used.

Return Value

None.

Example

rem ' BBjWebManager::setStyle

style$ = "color"
value$ = "blue"
selector$ = ".BBjStaticText"

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

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

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

window!.addStaticText(103,5,75,90,25,"Value:",$8000$)
value! = window!.addEditBox(104,100,75,475,25,value$,$$)

window!.addStaticText(105,5,125,90,25,"Selector:",$8000$)
selector! = window!.addEditBox(106,100,125,475,25,selector$,$$)

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

getStyle! = window!.addButton(202,100,225,475,25,"getStyle",$$)
getStyle!.setCallback(getStyle!.ON_BUTTON_PUSH,"getStyle")

getComputedStyle! = window!.addButton(203,100,275,475,25,"getComputedStyle",$$)
getComputedStyle!.setCallback(getComputedStyle!.ON_BUTTON_PUSH,"getComputedStyle")

browser! = bbjapi().getWebManager(err=oops)
browser!.getUrl(err=oops)

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()
    style!.setSize(width-125,25)
    value!.setSize(width-125,25)
    selector!.setSize(width-125,25)
    setStyle!.setSize(width-125,25)
    getStyle!.setSize(width-125,25)
return

setStyle:
    style$ = style!.getText()
    value$ = value!.getText()
    selector$ = selector!.getText()
    browser!.setStyle(style$, value$, selector$)
return

getStyle:
    style$ = style!.getText()
    selector$ = selector!.getText()
    value$ = browser!.getStyle(style$, selector$)
    value!.setText(value$)
return

getComputedStyle:
    style$ = style!.getText()
    selector$ = selector!.getText()
    value$ = browser!.getComputedStyle(style$, selector$)
    value!.setText(value$)
return

See Also

BBjAPI

BBjSysGui

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