BUI logoDWC logo BBjWebManager::hasAttribute

Description

In BBj 26.02 and higher, this method returns a boolean value indicating whether the selected element has the specified attribute.

Note:

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

Syntax

Return Value Method
void hasAttribute(String attribute)
void hasAttribute(String attribute, String selector)

Parameters

Parameter Description
attribute Specifies the name of an attribute.
selector By default, hasAttribute applies to the document element on the web page. If a selector is specified, it selects a descendant element within the document to query this attribute. If a specified selector doesn't return any elements, the default document element is used.

Return Value

Returns a boolean value indicating whether the selected element has the specified attribute.

Example

rem ' BBjWebManager::hasAttribute

attribute$ = "lang"
value$ = "en-US"
selector$ = ""

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

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

status! = window!.addStatusBar(99)

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

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$,$$)

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

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

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

removeAttribute! = window!.addButton(4,100,325,475,25,"removeAttribute",$$)
removeAttribute!.setCallback(hasAttribute!.ON_BUTTON_PUSH,"removeAttribute")

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()
  attribute!.setSize(width-125,25)
  value!.setSize(width-125,25)
  selector!.setSize(width-125,25)
  setAttribute!.setSize(width-125,25)
  getAttribute!.setSize(width-125,25)
  hasAttribute!.setSize(width-125,25)
  removeAttribute!.setSize(width-125,25)
return

setAttribute:
  attribute$ = attribute!.getText()
  value$ = value!.getText()
  selector$ = selector!.getText()
  status$ = "setAttribute "+attribute$+" = "+value$
  browser!.setAttribute(attribute$, value$, selector$)
  status!.setText(status$)
return

getAttribute:
  attribute$ = attribute!.getText()
  selector$ = selector!.getText()
  value$ = browser!.getAttribute(attribute$, selector$)
  status$ = "getAttribute "+attribute$+" = "+value$
  status!.setText(status$)
return

hasAttribute:
  attribute$ = attribute!.getText()
  selector$ = selector!.getText()
  has! = browser!.hasAttribute(attribute$, selector$)
  status$ = "hasAttribute "+attribute$+" = "+Boolean.toString(has!)
  status!.setText(status$)
return

removeAttribute:
  attribute$ = attribute!.getText()
  selector$ = selector!.getText()
  status$ = "removeAttribute "+attribute$
  browser!.removeAttribute(attribute$, selector$)
  status!.setText(status$)
return

See Also

BBjAPI

BBjSysGui

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