关于iframe引用的问题

Chapant 2007-10-10 03:00:32
<iframe id="myframe" src="top.htm"></iframe>
看过两种引用的方法:
1. document.all.myframe
2. document.frames.myframe

前一种好像可以当作一般的对象使用,像style等属性都可以使用,但是不能指定其页面的designMode属性
后一种就比较奇怪了,正常的属性不能使用,但却能用其指定designMode

究竟上面两种方法有什么区别,后一种究竟是个什么东东?
...全文
300 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Chapant 2007-10-10
  • 打赏
  • 举报
回复
多谢二位!
一位解决了我的问题,一位解决了我正想要问的问题,谢谢!
gzdiablo 2007-10-10
  • 打赏
  • 举报
回复
可以用下面的代替
1.document.getElementById("myframe");
2.document.getElementById("myframe").contentWindow;
JK_10000 2007-10-10
  • 打赏
  • 举报
回复
基本问题请问身边的同事或查参考资料,会受益更多:

---------
frames
--------------------------------------------------------------------------------

Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window.

Syntax

[ oColl = ] object.frames
[ oObject = ] object.frames(vIndex [, iSubIndex])

Possible Values

oColl Array of window objects.
oObject Reference to an individual item in the array of elements contained by the object.
vIndex Required. Integer or string that specifies the element or collection to retrieve. If this parameter is an integer, the method returns the element in the collection at the given position, where the first element has value 0, the second has 1, and so on. If this parameter is a string and there is more than one element with the name or id property equal to the string, the method returns a collection of matching elements.
iSubIndex Optional. Position of an element to retrieve. This parameter is used when vIndex is a string. The method uses the string to construct a collection of all elements that have a name or id property equal to the string, and then retrieves from this collection the element at the position specified by iSubIndex.
JK_10000 2007-10-10
  • 打赏
  • 举报
回复
1. document.all.myframe :返回的是<iframe>这个对象
2. document.frames.myframe 返回的是<iframe>里的页面的window对象

87,921

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧