FireFox 的父级 iframe 不起作用?

发布于 2024-12-14 01:59:34 字数 226 浏览 4 评论 0原文

我正在尝试从 iframe 更改输入变量(位于父窗口或主窗口中)的值。它在 IE8、Chrome 或 Safari 中工作正常,但在 FireFox 中则不行...

这是我的代码:

parent.NameOfTheInputVariable.value=_value_;

我做错了什么?我读到 Firefox 不接受“父”窗口...我怎样才能访问主窗口?

I'm trying to change de value of an input variable (located in the parent or main window) from an iframe. It works fine in IE8, Chrome or Safari, but not in FireFox...

This is my code:

parent.NameOfTheInputVariable.value=_value_;

What am I doing wrong? I've read that firefox doesn't accept the "parent" window... how can I access the main window?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

或十年 2024-12-21 01:59:34

问题不在于parent,而是假设仅仅因为某个东西有一个名字就会有一个全局变量。这是 WebKit 采用的一种非标准 IEism(尽管我认为它可能只能在 Quirks 模式下工作,无论如何最好避免这种情况)。

parent.document.getElementsByName('NameOfTheInputElement')[0].value = ...;

......应该完成这项工作。

The problem is not the parent, but assuming that there will be a global variable just because something has a name. That is a non-standard IEism that WebKit has adopted (although I think it may only work in Quirks mode, which is best avoided anyway).

parent.document.getElementsByName('NameOfTheInputElement')[0].value = ...;

… should do the job.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文