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

12-23-2006, 03: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!

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

That should be crossbrowser

12-23-2006, 08:31 AM
Thank you very much.