热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Firefox无法找到iframe-Firefoxnotabletofindiframe

ThisistheiframeImtryingtoaccess:这是我试图访问的iframe:<dividadditionalTxt

This is the iframe I'm trying to access:

这是我试图访问的iframe:

 

Using this line:

使用此行:

frames['additionalTxt_f'].document.getElementsByTagName("body")[0].innerHTML

For some reason I'm getting "frames.additionalTxt_f is undefined" from firebug. I have similar iframes (dynamically created by punyMCE plugin) on other pages, and they work perfectly fine. And IE7/8 has no problem accessing this iframe either.

出于某种原因,我从firebug得到“frames.additionalTxt_f未定义”。我在其他页面上有类似的iframe(由punyMCE插件动态创建),它们工作得很好。 IE7 / 8也可以访问这个iframe。

Just at a complete loss here. Any ideas on why Firefox can't find the iframe?

在这里完全失败了。关于Firefox无法找到iframe的任何想法?

2 个解决方案

#1


8  

The window.frames[] array is indexed by the [i]frame's name attribute (aka frame target). id can't be relied upon to also work — although it may in IE <8, which often thinks names and ids are the same thing.

window.frames []数组由[i]帧的名称属性(也称为帧目标)索引。不能依赖id也可以工作 - 虽然它可能在IE <8中,它通常认为名称和ID是相同的东西。

If you want to access a frame's content via ID, use the DOM Level 2 HTML contentDocument property instead of the old-school (“DOM Level 0”) frames array:

如果要通过ID访问框架的内容,请使用DOM Level 2 HTML contentDocument属性而不是old-school(“DOM Level 0”)框架数组:

document.getElementById('additionalTxt_f').contentDocument.body.innerHTML

...but then, for compatibility with IE <8, you also have to add some fallback cruft, since it doesn't support contentDocument:

...但是,为了兼容IE <8,你还必须添加一些后备,因为它不支持contentDocument:

var f= document.getElementById('additionalTxt_f');
var d= f.contentDocument? f.contentDocument : f.contentWindow.document;
d.body.innerHTML

So it's up to you which method you think is less ugly: the extra script work, or just using the name attribute.

因此,您认为哪种方法不那么难看:额外的脚本工作,或者仅使用name属性。

#2


1  

if you have only 1 iframe you can also find it with window.frames[1] or document.getElementsByTagName('iframe')[0]

如果您只有1个iframe,您也可以使用window.frames [1]或document.getElementsByTagName('iframe')[0]找到它

(In the first option, the parent window is #0)

(在第一个选项中,父窗口为#0)


推荐阅读
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • http:my.oschina.netleejun2005blog136820刚看到群里又有同学在说HTTP协议下的Get请求参数长度是有大小限制的,最大不能超过XX ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • python+selenium十:基于原生selenium的二次封装fromseleniumimportwebdriverfromselenium.webdriv ... [详细]
  • ImgettingabugwithInternetExplorer.Theiframedoesnthavecorrectsizeanditisdisplayedo ... [详细]
  • Java太阳系小游戏分析和源码详解
    本文介绍了一个基于Java的太阳系小游戏的分析和源码详解。通过对面向对象的知识的学习和实践,作者实现了太阳系各行星绕太阳转的效果。文章详细介绍了游戏的设计思路和源码结构,包括工具类、常量、图片加载、面板等。通过这个小游戏的制作,读者可以巩固和应用所学的知识,如类的继承、方法的重载与重写、多态和封装等。 ... [详细]
  • 本文介绍了闭包的定义和运转机制,重点解释了闭包如何能够接触外部函数的作用域中的变量。通过词法作用域的查找规则,闭包可以访问外部函数的作用域。同时还提到了闭包的作用和影响。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 本文介绍了Python爬虫技术基础篇面向对象高级编程(中)中的多重继承概念。通过继承,子类可以扩展父类的功能。文章以动物类层次的设计为例,讨论了按照不同分类方式设计类层次的复杂性和多重继承的优势。最后给出了哺乳动物和鸟类的设计示例,以及能跑、能飞、宠物类和非宠物类的增加对类数量的影响。 ... [详细]
  • 本文介绍了网页播放视频的三种实现方式,分别是使用html5的video标签、使用flash来播放以及使用object标签。其中,推荐使用html5的video标签来简单播放视频,但有些老的浏览器不支持html5。另外,还可以使用flash来播放视频,需要使用object标签。 ... [详细]
  • Apache Shiro 身份验证绕过漏洞 (CVE202011989) 详细解析及防范措施
    本文详细解析了Apache Shiro 身份验证绕过漏洞 (CVE202011989) 的原理和影响,并提供了相应的防范措施。Apache Shiro 是一个强大且易用的Java安全框架,常用于执行身份验证、授权、密码和会话管理。在Apache Shiro 1.5.3之前的版本中,与Spring控制器一起使用时,存在特制请求可能导致身份验证绕过的漏洞。本文还介绍了该漏洞的具体细节,并给出了防范该漏洞的建议措施。 ... [详细]
  • java.lang.Class.getDeclaredMethod()方法java.lang.Class.getDeclaredMethod()方法用法实例教程-方法返回一个Met ... [详细]
  • 重学前端学习笔记(十八)JavaScript的闭包和执行上下文
    笔记说明重学前端是程劭非(winter)【前手机淘宝前端负责人】在极客时间开的一个专栏,每天10分钟,重构你的前端知识体系,笔者主要整理学习过程的一些要点笔记以及感悟,完整的可以加 ... [详细]
  • Html5第一章
    Html5第一章 ... [详细]
  • 摘要:我很喜欢看各个产品的Bug追踪系统,比如jQuery的BugTracker,因为在Bug系统中总能发现一些非常细节的问题࿰ ... [详细]
author-avatar
呼呼小琰琰
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有