Reference Guide
facebook FBML Reference Guide Page 150 of 159
type getType setType
selectedIndex getSelectedIndex setSelectedIndex
selected getSelected setSelected
location n/a setLocation
style getStyle setStyle
n/a getRootElement
used as document.getRootElement - returns the top-
level element of your profile box or canvas page
Manipulating Styles
Styles are set with the setStyle method and queried with the getStyle method. setStyle can set multiple styles
using the syntax:
obj.setStyle({color: 'black', background: 'white'});
Or one style at a time using:
obj.setStyle('color', 'black');
Beware you need to camelize style names. This works:
obj.setStyle('textDecoration', 'underline')
But this won't:
obj.setStyle('text-decoration', 'underline')
You must also remember to use 'px' notation when referring to positions or height/width, and so forth.
This works:
obj.setStyle('width', '340px')
But this doesn't:
obj.setStyle('width', '340')
This is important to remember when you're using algorithms to calculate those values. You can't just use the
calculated variable x like: setStyle('left', x), but rather like setStyle('left', x+'px').
Additional functionality for manipulating CSS classes has been added to FBJS DOM nodes.
addClassName(className)
Adds a class name to the className string if it isn't already present.
removeClassName(className)
Removes a class name from the className string if it present.
toggleClassName(className)
If a class name exists, it removes it. If it doesn't exist it adds it.
hasClassName(className)
Returns true if the class name exists or false otherwise.
Setting Content
innerHTML isn't implemented for security reasons. Three alternatives exist.
1. obj.setTextValue(newText) can be used to set a literal text value inside of your DOM object (no HTML
or FBML accepted).
2. obj.setInnerFBML(fbJsStringVar) can be used to put HTML or FBML inside of your DOM object. Note
that you need to create a Fb:js-string object first and pass it in as passing a string literal will result in an
error.
3. obj.setInnerXHTML(string) is a beta feature that allows you to place a string of XHTML directly into
the document. The XHTML is sanitized in JavaScript before being rendered.
Working with Text Fields
www.yapish.com










