HTMLIFrameElement
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
* Some parts of this feature may have varying levels of support.
HTMLIFrameElement 接口提供了除 HTMLElement 之外的一些特殊属性和方法(当然也包括了继承自 HTMLElement 的部分)。这些方法用于操作内联 frame 元素的布局和展示。
属性
继承了来自父类的属性,HTMLElement。
HTMLIFrameElement.align已弃用-
一个
DOMString指定了相对于当前上下文的对齐方式。 HTMLIFrameElement.allowfullscreen实验性-
一个
Boolean标识了该内联 frame 是否愿意被全屏防止。详情请参考 Using full-screen mode 。 HTMLIFrameElement.contentDocument只读-
返回一个
Document,该内联 frame 嵌套的浏览上下文中活跃的 document 对象。 HTMLIFrameElement.contentWindow只读-
返回一个
WindowProxy,该嵌套的浏览上下文中的 window 代理。 HTMLIFrameElement.frameBorder已弃用-
一个
DOMString标识了是否在 frame 之间创建边框。 HTMLIFrameElement.heightHTMLIFrameElement.longDesc已弃用-
一个
DOMString包含着该 frame 的详细描述的 URI。 HTMLIFrameElement.marginHeight已弃用-
一个
DOMString,该 frame 的外边距高度。 HTMLIFrameElement.marginWidth已弃用-
一个
DOMString,该 frame 的外边距宽度。 HTMLIFrameElement.nameHTMLIFrameElement.referrerPolicy实验性-
一个
DOMString反映着referrerpolicyHTML 属性,标识了获取关联资源时要使用哪个 referrer。 HTMLIFrameElement.sandbox-
一个
DOMSettableTokenList反映着sandboxHTML 属性,指示着对嵌套内容额外的限制。 HTMLIFrameElement.scrolling已弃用-
一个
DOMString指示着浏览器是否应该为该 frame 提供滚动条。 HTMLIFrameElement.srcHTMLIFrameElement.srcdoc-
一个
DOMString,表示该 frame 中要显示的内容。 HTMLIFrameElement.width
方法
继承了来自父类的属性,HTMLElement。
浏览器 API 方法
为支持浏览器<iframe>的需求,HTMLIFrameElement已经扩展了一些新的方法来让<iframe>有更多的能力。他们并未成为规范(参见 Browser compatibility)。
导航方法
以下导航方法允许通过<iframe>的浏览历史进行导航。他们对于后退、前进、停止和重新加载按钮的实现而言是非常必须的。
HTMLIFrameElement.reload()-
重新加载
<iframe>元素内容。 HTMLIFrameElement.stop()-
停止加载
<iframe>元素内容。 HTMLIFrameElement.getCanGoBack()-
指示是否可以后退。
HTMLIFrameElement.goBack()-
改变
<iframe>位置到上一个浏览历史记录的位置。 HTMLIFrameElement.getCanGoForward()-
指示是否可以前进。
HTMLIFrameElement.goForward()-
改变
<iframe>位置到下一个浏览历史记录的位置。
管理方法
这个方法集管理浏览器<iframe>所用的资源。它们对于实现分页浏览程序非常有用。
HTMLIFrameElement.executeScript()-
在浏览器
<iframe>页面加载完成后执行指定的脚本。 HTMLIFrameElement.purgeHistory()-
清理所有与浏览器
<iframe>有关的资源(不包括 cookie)。 HTMLIFrameElement.setVisible()-
修改浏览器
<iframe>的可见性。这会影响资源分配和一些函数的资源占用率,如requestAnimationFrame。 HTMLIFrameElement.getVisible()-
指示当前浏览器
<iframe>的可见性。 HTMLIFrameElement.setActive()-
设置当前
<iframe>为活动 frame,对进程管理器如何划分优先级有影响。 HTMLIFrameElement.getActive()-
指示当前浏览器
<iframe>是否为当前活动的 frame。 HTMLIFrameElement.setInputMethodActive()-
设置当前浏览器
<iframe>是活动的输入法编辑器窗口而其他不是。当一个顶层应用希望激活一个窗口作为输入法编辑器(如键盘)时有用。 HTMLIFrameElement.setNfcFocus()-
Firefox 操作系统 NFC API 的一部分,扩展了Browser API,这个集合设置浏览器
<iframe>是否可以接收一个NFC事件。
音频相关方法
以下方法允许直接控制浏览器元素的声音。
HTMLIFrameElement.getVolume()-
获取浏览器
<iframe>当前音量。 HTMLIFrameElement.setVolume()-
设置浏览器
<iframe>当前音量。 HTMLIFrameElement.mute()-
浏览器
<iframe>播放的所有音频静音。 HTMLIFrameElement.unmute()-
取消浏览器
<iframe>播放所有音频的静音。 HTMLIFrameElement.getMuted()-
指示当前浏览器
<iframe>当前是否被静音。
Search methods
New methods are provided to allow programmatic searches of browser <iframe>s to be carried out.
HTMLIFrameElement.findAll()-
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()-
Highlights the next or previous instance of a search result after a
findAll()search has been carried out. HTMLIFrameElement.clearMatch()-
Clears any content highlighted by
findAll()orfindNext().
Event-related methods
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 theEventTargetinterface -
addEventListener(),removeEventListener(), anddispatchEvent(). HTMLIFrameElement.sendMouseEvent()-
Sends a
MouseEventto the<iframe>'s content. HTMLIFrameElement.sendTouchEvent()-
Sends a
TouchEventto 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
MozAfterPaintevent 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()-
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()-
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 |
|---|
| HTML> # htmliframeelement> |
Browser compatibility
Loading…
See also
- The HTML element implementing this interface:
<iframe>