为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Javascript: parent.framename.document.forms[i].elements.length

more options

I have a PHP-Script 1 with an iframe. In this iframe an other PHP-Script 2 is loaded, which contains several forms. In one of this forms I make a call by button with onclick="..." to a javascript-function. The javascript-function is contained in an external file *.js. Declaration in PHP-Script 2: <Script type="text/javascript" src="WartArtikel-Probe.js"></Script>. Inside the javascript-function I use: Scenario 1: var i = 0; var anzelem = parent.framename.document.forms[i].elements.length; or: var anzelem = parent.frames[0].document.forms[i].elements.length; or: var anzelem = window.document.forms[i].elements.length;

When I press the button, the javascript-function gives no answer. But when I start PHP-Script 2 directly (not inside an iframe) and the javascript-function is written as: Scenario 2: var i = 0; var anzelem = document.forms[i].elements.length; this example works! How can I get an answer in scenario 1?

Additional suggestion: Is it possible to switch the browser into a development-modus, where javascript-syntax-errors are displayed? This could be very helpful!

I have a PHP-Script 1 with an iframe. In this iframe an other PHP-Script 2 is loaded, which contains several forms. In one of this forms I make a call by button with onclick="..." to a javascript-function. The javascript-function is contained in an external file *.js. Declaration in PHP-Script 2: &lt;Script type="text/javascript" src="WartArtikel-Probe.js"&gt;&lt;/Script&gt;. Inside the javascript-function I use: Scenario 1: var i = 0; var anzelem = parent.framename.document.forms[i].elements.length; or: var anzelem = parent.frames[0].document.forms[i].elements.length; or: var anzelem = window.document.forms[i].elements.length; When I press the button, the javascript-function gives no answer. But when I start PHP-Script 2 directly (not inside an iframe) and the javascript-function is written as: Scenario 2: var i = 0; var anzelem = document.forms[i].elements.length; this example works! How can I get an answer in scenario 1? Additional suggestion: Is it possible to switch the browser into a development-modus, where javascript-syntax-errors are displayed? This could be very helpful!

由cor-el于修改

所有回复 (1)

more options

To view script errors, you can keep the Browser Console open in a separate window. To open that, you can use either:

  • Ctrl+Shift+j
  • "3-bar" menu button > Developer > Browser Console
  • Tools menu > Web Developer > Browser Console

My guess is you will find some kind of security related issue.