Skip to content
premasagar edited this page Sep 13, 2010 · 14 revisions

Except where otherwise stated, all methods return the AOMI object itself, to allow method chaining.

$()

A shortcut for document(). This is analagous to the jQuery method $.(), which returns the global document object.

$(selector)

Returns a set of elements from the iframe’s document body, matching the CSS selector.
This identical to: jQuery(selector, aomi.body())

window()

Returns the iframe’s window object, wrapped in a jQuery object.

If the window object cannot be accessed (e.g. because the iframe is not in the DOM, or the iframe is displaying a document from a different domain), then an an empty jQuery collection, with zero length, is returned.

document()

Returns the iframe’s document object, wrapped in a jQuery object.

If the document object cannot be accessed (e.g. because the iframe is not in the DOM, or the iframe is displaying a document from a different domain), then an an empty jQuery collection, with zero length, is returned.

document([headContents], [bodyContents], [options], [callback])

Re-creates the iframe document, in the same way as a call to $.iframe(headContents, bodyContents, options, callback).

body()

Returns the body element of the iframe’s document, wrapped in a jQuery object.

If the body element cannot be accessed (e.g. because the iframe is not in the DOM, or the iframe is displaying a document from a different domain), then an an empty jQuery collection, with zero length, is returned.

body(contents, [emptyFirst])

  • contents will be appended to the iframe’s body element. May be an HTML string, DOM node, jQuery collection, or selector.
  • emptyFirst is an optional boolean (default false). If true, the body element will first be emptied of all child nodes.

head()

Returns the head element of the iframe’s document, wrapped in a jQuery object.

If the head element cannot be accessed (e.g. because the iframe is not in the DOM, or the iframe is displaying a document from a different domain), then an an empty jQuery collection, with zero length, is returned.

head(contents, [emptyFirst])

  • contents will be appended to the iframe’s head element. May be an HTML string, DOM node, jQuery collection, or selector.
  • emptyFirst is an optional boolean (default false). If true, the head element will first be emptied of all child nodes.

style(cssText)

Appends a new <style> element to the iframe document’s head, using the cssText as the style contents.

resize([doWidth], [doHeight])

Resizes the iframe element to fit the iframe document’s body, which can be useful after elements are added or removed to the body, or CSS is changed.

If no arguments are passed, then the AOMI options autoheight and autowidth are used to determine the values of doWidth and doHeight. The default values are true for the height and false for the width.

Further explanation on the default behaviour: The AOMI object will attempt to act like a standard block-level element (e.g. a <div>). It will auto-resize its height when child elements are added and removed, but it won’t auto-resize its width to the child elements. Instead, like a <div>, the iframe will automatically stretch to fill its containing space, using the CSS width:100%;.

Clone this wiki locally