Skip to content

API: Advanced methods

premasagar edited this page Sep 13, 2010 · 11 revisions

hasExternalDocument()

Returns true if the iframe contains a document that is from an external resource (either from the same domain, or not), as opposed to a document that has been created by JavaScript on-the-fly, or a null document (due to the iframe being out of the DOM, or the document never having been created). Otherwise false.

isSameDomain()

Returns true if the iframe contains a document that either a) has been created by JavaScript on-the-fly, or b) is from an external resource from the same domain as the host document. In such cases, JavaScript from the host document has full rights to read from and write to the iframe’s document. Otherwise false.

hasBlankSrc()

Returns true if the iframe element has a src attribute of "about:blank", or a blank string, or null. Otherwise false.

title()

Returns the iframe document’s title property.

title(newTitle)

Sets the iframe document’s title property.

doctype()

Returns the iframe document’s doctype string, e.g. <!DOCTYPE html>.

doctype(htmlVersion)

Uses the htmlVersion to determine the doctype that will be used when the iframe document is created.
The default is the HTML5 doctype: aomi.doctype(5).

location()

Returns the iframe window’s location, if it can be determined (this will happen if the iframe is in the DOM and it has a document from the same domain as the host document). If not, then the method will either return the iframe element’s src attribute (if the iframe is out of the DOM and has a document from the same domain as the host document), or otherwise null.

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%;.

restore()

options()

reload()

clone()

replace()

repaint()

Clone this wiki locally