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.
Inherits properties from its parent, HTMLElement.
HTMLIFrameElement.align
DOMString that specifies the alignment of the frame with respect to the surrounding context.HTMLIFrameElement.allow
self and src which represent the origin in the iframe's src attribute. The default value is src.HTMLIFrameElement.allowfullscreen
Boolean indicating whether the inline frame is willing to be placed into full screen mode. See Using full-screen mode for details.HTMLIFrameElement.allowPaymentRequestBoolean indicating whether the Payment Request API may be invoked inside a cross-origin iframe.HTMLIFrameElement.contentDocument Read only
Document, the active document in the inline frame's nested browsing context.HTMLIFrameElement.contentWindow Read only
WindowProxy, the window proxy for the nested browsing context.HTMLIFrameElement.frameBorder
DOMString that indicates whether to create borders between frames.HTMLIFrameElement.heightDOMString that reflects the height HTML attribute, indicating the height of the frame.HTMLIFrameElement.longDesc
DOMString that contains the URI of a long description of the frame.HTMLIFrameElement.marginHeight
DOMString being the height of the frame margin.HTMLIFrameElement.marginWidth
DOMString being the width of the frame margin.HTMLIFrameElement.nameDOMString that reflects the name HTML attribute, containing a name by which to refer to the frame.HTMLIFrameElement.referrerPolicy
DOMString that reflects the referrerpolicy HTML attribute indicating which referrer to use when fetching the linked resource.HTMLIFrameElement.sandboxDOMSettableTokenList that reflects the sandbox HTML attribute, indicating extra restrictions on the behavior of the nested content.HTMLIFrameElement.scrolling
DOMString that indicates whether the browser should provide scrollbars for the frame.HTMLIFrameElement.srcDOMString that reflects the src HTML attribute, containing the address of the content to be embedded.HTMLIFrameElement.srcdocDOMString that represents the content to display in the frame.HTMLIFrameElement.widthDOMString that reflects the width HTML attribute, indicating the width of the frame.Inherits properties from its parent, HTMLElement.
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()<iframe> element content.HTMLIFrameElement.stop()<iframe>'s content loading.HTMLIFrameElement.getCanGoBack()HTMLIFrameElement.goBack()<iframe> for the previous location in its browsing history.HTMLIFrameElement.getCanGoForward()HTMLIFrameElement.goForward()<iframe> for the next location in its browsing history.The next set of methods manage the resources used by a browser <iframe>. These are especially useful for implementing tabbed browser application.
HTMLIFrameElement.executeScript()<iframe>.HTMLIFrameElement.purgeHistory()<iframe>.HTMLIFrameElement.setVisible()<iframe>. This can influence resource allocation and some function usage such as requestAnimationFrame.HTMLIFrameElement.getVisible()<iframe>.HTMLIFrameElement.setActive()<iframe> as the active frame, which has an effect on how it is prioritized by the process manager.HTMLIFrameElement.getActive()<iframe> is the currently active frame.The following methods allow direct control of sound in the browser element.
HTMLIFrameElement.getVolume()<iframe>.HTMLIFrameElement.setVolume()<iframe>.HTMLIFrameElement.mute()<iframe>.HTMLIFrameElement.unmute()<iframe>.HTMLIFrameElement.getMuted()<iframe> is currently muted.New methods are provided to allow programmatic searches of browser <iframe>s to be carried out.
HTMLIFrameElement.findAll()<iframe>'s content; if found, the first instance of the string relative to the caret position will be highlighted.HTMLIFrameElement.findNext()findAll() search has been carried out.HTMLIFrameElement.clearMatch()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:
<iframe> gains support for the methods of the EventTarget interfaceaddEventListener(), removeEventListener(), and dispatchEvent().HTMLIFrameElement.sendMouseEvent()MouseEvent to the <iframe>'s content.HTMLIFrameElement.sendTouchEvent()TouchEvent to the <iframe>'s content. Note that this method is available for touch enabled devices only.HTMLIFrameElement.addNextPaintListener()MozAfterPaint event in the browser <iframe>.HTMLIFrameElement.removeNextPaintListener()addNextPaintListener().Last, there are some utility methods, useful for apps that host a browser <iframe>.
HTMLIFrameElement.download()HTMLIFrameElement.getContentDimensions()HTMLIFrameElement.getManifest()<iframe> and returns it as JSON.HTMLIFrameElement.getScreenshot()<iframe>'s content. This is particularly useful to get thumbnails of tabs in a tabbed browser app.HTMLIFrameElement.getStructuredData()<iframe> and returns it as JSON.HTMLIFrameElement.zoom()<iframe>'s content. This is particularly useful for zooming in/out on non-touch-enabled devices.| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|---|
| Basic support | (Yes) | (Yes) | 1.0 (1.7 or earlier) | (Yes) | (Yes) | (Yes) |
srcdoc | 4 | (Yes) | 25 (25) | No support | ? | ? |
sandbox | 4 | (Yes) | 17 (17)[1] | ? | ? | ? |
contentDocument | (Yes) | (Yes) | (Yes) | 8.0[3] | (Yes) | (Yes) |
contentWindow | (Yes) | (Yes) | ? | (Yes) | ? | ? |
allowFullScreen
| 17 -webkit[4] | (Yes) |
9.0 (9.0) -moz 18.0 (18.0) | No support | No support | No support |
referrerPolicy
| 51 | No support | 50 (50) | No support | No support | No support |
| Browser API methods | No support | No support | No support[5] | No support | No support | No support |
allowPaymentRequest | 61 | ? | ? | ? | No support | ? |
allow property | 60 | ? | ? | ? | 47 | ? |
| Feature | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|---|
| Basic support | (Yes) | (Yes) | (Yes) | 1.0 (1.0) | (Yes) | (Yes) | (Yes) |
srcdoc | 4 | 4 | (Yes) | 25.0 (25) | ? | ? | ? |
sandbox | 4 | 4 | (Yes) | 17.0 (17)[1] | ? | ? | ? |
seamless
| 4 | 4 | No support | No support | ? | ? | ? |
contentDocument | (Yes) | (Yes) | (Yes) | (Yes) | ? | (Yes) | (Yes) |
contentWindow | (Yes) | (Yes) | (Yes) | ? | ? | ? | ? |
allowFullScreen
| 17 -webkit[4] | 17 -webkit[4] | (Yes) | 9.0 (9.0) -moz 18.0 (18.0) | No support | No support | No support |
referrerPolicy
| 51 | 51 | No support | 50.0 (50) | No support | No support | No support |
| Browser API methods | No support | No support | No support | No support | No support | No support | No support |
allowPaymentRequest | No support | 57 | ? | ? | ? | No support | ? |
allow property | 60 | 60 | ? | ? | ? | 47 | ? |
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.HTMLIFrameElement.contentWindow.document instead.<iframe>
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement