The IFrame object represents an HTML inline frame. For each instance of an HTML <iframe> tag in a document, an IFrame object is created.
IFrame 对象代表HTML 轴向(内)框架。当HTML中<iframe>标签,Iframe对象就建立了
IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).
Properties属性
Property
属性 |
Description
描述 |
IE |
F |
N |
W3C |
| align |
Sets or returns how to align the iframe according to the surrounding text
设置或获取排列。 |
5 |
1 |
6 |
Yes |
| contentDocument |
Returns the document the iframe contains
文档框架的内容 |
- |
1 |
6 |
Yes |
| frameBorder |
Sets or returns whether to display a border for the iframe
设置或获取框架间的空间,包括 3D 边框。 |
5 |
|
|
Yes |
| height |
Sets or returns the height of the iframe
设置或获取对象的高度。 |
5 |
|
|
Yes |
| id |
Sets or returns the id of the iframe (In IE 4 this property is read-only)
获取标识对象的字符串。 |
4 |
1 |
|
No |
| longDesc |
Sets or returns a URL to a long description of the iframe
设置或获取对象长描述的统一资源标识符(URI)。 |
6 |
|
|
Yes |
| marginHeight |
Sets or returns the top and bottom margins of the iframe
设置或获取显示框架中文本之前的上下边距高度。 |
5 |
1 |
6 |
Yes |
| marginWidth |
Sets or returns the left and right margins of the frame
设置或获取显示框架中文本之前的左右边距宽度。 |
5 |
1 |
6 |
Yes |
| name |
Sets or returns the name of the iframe
设置或获取框架的名称。 |
5 |
|
|
Yes |
| scrolling |
Sets or returns whether the iframe can be scrolled
设置或获取框架是否可被滚动。 |
5 |
1 |
6 |
Yes |
| src |
Sets or returns the URL to be loaded by the iframe
设置或获取要由对象装入的 URL。 |
5 |
1 |
6 |
Yes |
| tabIndex |
Sets or returns the index that defines the tab order for the iframe
设置或获取定义对象的 Tab 顺序的索引。 |
5 |
|
|
No |
| width |
Sets or returns the width of the iframe
设置或获取对象的宽度。 |
5 |
|
|
Yes |
Methods方法
Method
方法 |
Description
描述 |
IE |
F |
N |
W3C |
| blur() |
Removes focus from the iframe
取消对iframe的聚焦 |
5 |
|
|
No |
| focus() |
Gives focus to the iframe
让iframe得到聚焦 |
5 |
|
|
No |
Events事件
语法: object.event_name="someJavaScriptCode"
Event
事件 |
Description
描述 |
IE |
F |
N |
W3C |
| onBlur |
Executes some code when the iframe loses focus
当iframe失去焦点的时候执行代码 |
5 |
|
|
No |
| onFocus |
Executes some code when the iframe gets focus
当iframe得到焦点的时候执行代码 |
5 |
|
|
No |
通常要隐藏iframe的边框时需要用到frameborder属性,例如使用Dreamweaver可以生成如下代码:
<iframe frameborder=0 src='xxxx' width='xxx' height='xxx'></iframe>
但是如果使用DOM方式来生成一个iframe时IE却始终隐藏不了边框,例如:
var iframeCell = document.createElement('iframe');
iframeCell.setAttribute('frameborder',0); // Firefox下有效,IE下无效
经过高人指点,发现是大小写的原因,改为:
iframeCell.setAttribute('frameBorder',0); // Firefox和IE均有效
汗!frameBorder居然在CSS手册中查不到,故立刻记录下来,以备不时之需。
附:目前已知的DOM和HTML拼写有区别的属性(不断添加……)
HTML / DREAMWEAVER DOM
--------------------------------------------------------------------------------
frameborder frameBorder
cellspacing cellSpacing
cellpadding cellPadding
bgcolor bgColor
colspan colSpan
rowspan rowSpan