為了改善您的使用體驗,本網站正在進行維護,部分功能暫時無法使用。若本站的文件無法解決您的問題,想要向社群發問的話,請到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 發問,我們的社群成員將很快會回覆您的疑問。

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

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.