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

$.iframe()

Returns an iframe element, wrapped inside a standard jQuery collection – i.e. $('<iframe></iframe>') – that has been extended with some additional methods (for details on these, see below). This extended collection object is referred to here as an “AppleOfMyIframe” or “AOMI” object.

$.iframe([headContents], [bodyContents], [options], [callback])

All arguments are optional:

  • headContents (string):
    An HTML string to be appended to the iframe document’s <head> element, once the iframe loads.
  • bodyContents (string):
    An HTML string to be appended to the iframe document’s <body> element, once the iframe loads.
  • options (object):
    An object of different options to use when initialising the iframe. See API: Options.
  • callback (function):
    A function that will be called when the iframe is ready. This fires after the AOMI object’s ‘ready’ event and before its ‘load’ event. See API: Events.

$.iframe(url, [options], [callback])

Here, the url for an external document is loaded into the iframe. The options and callback parameters are as above.

$(elem).intoIframe()

Replace elements in the host document with an iframe, and inject those replaced elements into the iframe’s body.
E.g. $('div#something').intoIframe();

Clone this wiki locally