Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Unsere Freiwilligen haben diesen Artikel noch nicht in Deutsch übersetzt. Machen Sie mit und helfen Sie, das zu erledigen!

The HTMLIFrameElement interface provides special properties and methods (beyond those of the HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of inline frame elements.

Properties

Inherits properties from its parent, HTMLElement.

HTMLIFrameElement.align
Is a DOMString that specifies the alignment of the frame with respect to the surrounding context.
HTMLIFrameElement.allowfullscreen
Is a Boolean that indicates whether or not the inline frame is willing to be placed into full screen mode. See Using full-screen mode for details.
HTMLIFrameElement.contentDocument Read only
Returns a Document, the active document in the inline frame's nested browsing context.
HTMLIFrameElement.contentWindow Read only
Returns a WindowProxy, the window proxy for the nested browsing context.
HTMLIFrameElement.frameBorder
Is a DOMString that indicates whether to create borders between frames.
HTMLIFrameElement.height
Is a DOMString that reflects the height HTML attribute, indicating the height of the frame.
HTMLIFrameElement.longDesc
Is a DOMString that contains the URI of a long description of the frame.
HTMLIFrameElement.marginHeight
Is a DOMString being the height of the frame margin.
HTMLIFrameElement.marginWidth
Is a DOMString being the width of the frame margin.
HTMLIFrameElement.name
Is a DOMString that reflects the name HTML attribute, containing a name by which to refer to the frame.
HTMLIFrameElement.referrerPolicy
Is a DOMString that reflects the referrerpolicy HTML attribute indicating which referrer to use when fetching the linked resource.
HTMLIFrameElement.sandbox
Is a DOMSettableTokenList that reflects the sandbox HTML attribute, indicating extra restrictions on the behavior of the nested content.
HTMLIFrameElement.scrolling
Is a DOMString that indicates whether the browser should provide scrollbars for the frame.
HTMLIFrameElement.src
Is a DOMString that reflects the src HTML attribute, containing the address of the content to be embedded.
HTMLIFrameElement.srcdoc
Is a DOMString that represents the content to display in the frame.
HTMLIFrameElement.width
Is a DOMString that reflects the width HTML attribute, indicating the width of the frame.

Methods

Inherits properties from its parent, HTMLElement.

Browser API methods

To support the requirement of a browser <iframe>, HTMLIFrameElement has been extended with new methods that give the <iframe> some super powers. These are non-standard (see Browser compatibility.)

The following navigation methods allow navigation through the browsing history of the <iframe>. They are necessary to be able to implement back, forward, stop, and reload buttons.

HTMLIFrameElement.reload()
Allows reloading of the <iframe> element content.
HTMLIFrameElement.stop()
Allows stopping of the <iframe>'s content loading.
HTMLIFrameElement.getCanGoBack()
Indicates whether it's possible to navigate backwards.
HTMLIFrameElement.goBack()
Changes the location of the <iframe> for the previous location in its browsing history.
HTMLIFrameElement.getCanGoForward()
Indicates whether it's possible to navigate forward.
HTMLIFrameElement.goForward()
Changes the location of the <iframe> for the next location in its browsing history.

Management methods

The next set of methods manage the resources used by a browser <iframe>. These are especially useful for implementing tabbed browser application.

HTMLIFrameElement.executeScript()
Allows a specified script to be executed against a page loaded in the browser <iframe>.
HTMLIFrameElement.purgeHistory()
Clears all the resources (cookies, localStorage, cache, etc.) associated with the browser <iframe>.
HTMLIFrameElement.setVisible()
Changes the visibility state of a browser <iframe>. This can influence resource allocation and some function usage such as requestAnimationFrame.
HTMLIFrameElement.getVisible()
Indicates the current visibility state of the browser <iframe>.
HTMLIFrameElement.setActive()
Sets the current <iframe> as the active frame, which has an effect on how it is prioritized by the process manager.
HTMLIFrameElement.getActive()
Indicates whether the current browser <iframe> is the currently active frame.
HTMLIFrameElement.setInputMethodActive()
Sets the current browser <iframe> as an active IME window and other iframes as non-active IME windows. Useful when a top level app wants to activate a window as an IME (Input Method Editor, like a keyboard.)
HTMLIFrameElement.setNfcFocus() Firefox OS 2.2+ Only
Part of the Firefox OS NFC API, extending the Browser API, this sets whether a browser <iframe> can receive an NFC event.

The following methods allow direct control of sound in the browser element.

HTMLIFrameElement.getVolume() Firefox OS 2.5+ Only
Gets the current volume of the browser <iframe>.
HTMLIFrameElement.setVolume() Firefox OS 2.5+ Only
Sets the current volume of the browser <iframe>.
HTMLIFrameElement.mute() Firefox OS 2.5+ Only
Mutes any audio playing in the browser <iframe>.
HTMLIFrameElement.unmute() Firefox OS 2.5+ Only
Unmutes any audio playing in the browser <iframe>.
HTMLIFrameElement.getMuted() Firefox OS 2.5+ Only
Indicates whether the browser <iframe> is currently muted.

Search methods

New methods are provided to allow programmatic searches of browser <iframe>s to be carried out.

HTMLIFrameElement.findAll() Firefox OS 2.5+ Only
Searches for a string in a browser <iframe>'s content; if found, the first instance of the string relative to the caret position will be highlighted.
HTMLIFrameElement.findNext() Firefox OS 2.5+ Only
Highlights the next or previous instance of a search result after a findAll() search has been carried out.
HTMLIFrameElement.clearMatch() Firefox OS 2.5+ Only
Clears any content highlighted by findAll() or findNext().

In order to manage the browser <iframe>'s content, many new events were added (see below). The following methods are used to deal with those events:

The <iframe> gains support for the methods of the EventTarget interface
addEventListener(), removeEventListener(), and dispatchEvent().
HTMLIFrameElement.sendMouseEvent()
Sends a MouseEvent to the <iframe>'s content.
HTMLIFrameElement.sendTouchEvent()
Sends a TouchEvent to the <iframe>'s content. Note that this method is available for touch enabled devices only.
HTMLIFrameElement.addNextPaintListener()
Defines a handler to listen for the next MozAfterPaint event in the browser <iframe>.
HTMLIFrameElement.removeNextPaintListener()
Removes a handler previously set with addNextPaintListener().

Utility methods

Last, there are some utility methods, useful for apps that host a browser <iframe>.

HTMLIFrameElement.download()
Downloads a specified URL, storing it at the specified filename/path.
HTMLIFrameElement.getContentDimensions()
Retrieves the X and Y dimensions of the content window.
HTMLIFrameElement.getManifest() Firefox OS 2.5+ Only
Retrieves the manifest of an app loaded in the browser <iframe> and returns it as JSON.
HTMLIFrameElement.getScreenshot()
Takes a screenshot of the browser <iframe>'s content. This is particularly useful to get thumbnails of tabs in a tabbed browser app.
HTMLIFrameElement.getStructuredData() Firefox OS 2.5+ Only
Retrieves any structured microdata (and hCard and hCalendar microformat data) contained in the HTML loaded in the browser <iframe> and returns it as JSON.
HTMLIFrameElement.zoom()
Changes the zoom factor of the browser <iframe>'s content. This is particularly useful for zooming in/out on non-touch-enabled devices.

Specifications

Specification Status Comment
Referrer Policy
The definition of 'referrer attribute' in that specification.
Working Draft Added the referrerPolicy property.
WHATWG HTML Living Standard
The definition of 'HTMLIFrameElement' in that specification.
Living Standard The following property has been added: allowFullscreen.
HTML5
The definition of 'HTMLIFrameElement' in that specification.
Recommendation The following properties are now obsolete: scrolling, marginWidth, marginHeight, longDesc, frameBorder, and align.
The following properties have been added: srcdoc, sandbox, and contentWindow.
Document Object Model (DOM) Level 2 HTML Specification
The definition of 'HTMLIFrameElement' in that specification.
Recommendation The contentDocument property has been added.
Document Object Model (DOM) Level 1 Specification
The definition of 'HTMLIFrameElement' in that specification.
Recommendation Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) 1.0 (1.7 or earlier) (Yes) (Yes) (Yes)
srcdoc 4 25 (25) ? ? ?
sandbox 4 17 (17)[1] ? ? ?
contentDocument (Yes) (Yes) 8.0[3] (Yes) (Yes)
contentWindow ? ? (Yes) ? ?
allowFullScreen 17 -webkit[4] 9.0 (9.0) -moz
18.0 (18.0)
No support No support No support
referrerPolicy No support 50 (50) No support No support No support
Browser API methods No support No support[5] No support No support No support
Feature Android Firefox Mobile (Gecko) Firefox OS (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support (Yes) 1.0 (1.0) 1.0.1 (Yes) (Yes) (Yes)
srcdoc 4 25.0 (25) 1.1 ? ? ?
sandbox 4 17.0 (17)[1] 1.0.1 ? ? ?
seamless 4 No support No support ? ? ?
contentDocument (Yes) (Yes) 1.0.1 ? (Yes) (Yes)
contentWindow ? ? 1.0.1 ? ? ?
allowFullScreen 17 -webkit[4] 9.0 (9.0) -moz
18.0 (18.0)
1.0.1 No support No support No support
referrerPolicy No support 50.0 (50) 2.5 No support No support No support
Browser API methods No support No support 1.0.1[2] No support No support No support
  • [1] Previously, the type of sandbox was a DOMString instead of a DOMSettableTokenList. This has been fixed with Gecko 29.0 (Firefox 29 / Thunderbird 29 / SeaMonkey 2.26)) (bug 845067). Other browsers may still implement the property as DOMString since it was a late change in the specification.
  • [2] Requires privileged app, and browser and/or embed-apps permissions, depending on what you want to do. See Using the Browser API for more details. Most of the proprietary Browser API methods are supported from Firefox OS 1.0.1 onwards; they are marked where this is not the case.
  • [3] For older version use HTMLIFrameElement.contentWindow.document instead.
  • [4] Daily test builds only.
  • [5] Supported in chrome code only.

See also

  • The HTML element implementing this interface: <iframe>

Schlagwörter des Dokuments und Mitwirkende

Schlagwörter: 
 Zuletzt aktualisiert von: fscholz,