View Full Version : Javascript "forms" problem in Internet Explorer

Dec 23rd, 2006, 02:32 AM
I have a a form in an iframe whose values are retrieved by javascript.
The retrieval works fine in Safari and Firefox but I get an error Internet Explorer (what else is new?). Here is the line I currently have:

var my_form = document.getElementById("iframe_page").contentDocument.forms["page_form"+i];


Here is the error I get from Internet Explorer:

" 'document.getElementById(...).contentDocument.forms' is null or not an object "

This same object, however, is retrieved without a problem, as I said, in Firefox and Safari.

As you can see there are several forms on the page [accessed by the i variable]

Is there a special case for internet explorer to get this same code to work?
If so what is the call I make in the 'var my_form = ....' line?

Thanks a ton!

Dec 23rd, 2006, 04:57 AM
var my_form = document.getElementById("iframe_page").contentWindow.document.forms["page_form"+i];

That should be crossbrowser

Dec 23rd, 2006, 07:31 AM
Thank you very much.