Z
Zhang Weiwu
This is really very stange. I have a form like this:
<form id="form_A"> xxxx </form>
This form is on one page in a page of a web application, it is the only
form on that page. on the end of the page in javascript:
document.getElementById("form_A").submit();
In the begining it works very well, after I restarted the browser and
did some small modification (I don't recall, but far from chaning that
form or script), it doesn't work. After some debuging it shows
document.getElementById("form_A") gets nothing, element with this ID
does not exist.
I tried so many debugging:
1) if change <form id="form_A"> to <div id="form_A"> then
document.getElementById("form_A") works
2) if move <form id="form_A"> to just below <body> then
document.getElementById("form_A") works
3) if move <form id="form_A"> to just above </body> then
document.getElementById("form_A") return nothing
4) if move <form id="form_A"> to random place in the webpage
document.getElementById("form_A") return nothing
5) if remove all other javascript on that page, only have the HTML and
one line of javascript document.getElementById("form_A"), except if we
put the form just below <body>, otherwise
document.getElementById("form_A") return nothing
6) use HTMLTIDY it shows only warning but no error
all above are tested on mozilla 1.7.8, I picked up random cases to test
on Opera 8.0 Final, same behavor as on moz.
in all above case, if document.getElementById("form_A") return nothing,
other means to retrive the <form> element all failed. Including
* addresssing the form by "name" attribute;
* getElementsByTagName('form');
* alert(fatherelement.innerHTML).
It just vanishes perfectly! E.g if I display html.innerHTML then in the
dialogue box the whole HTML source is displayed, PERFECTLY without the
<form>
Any idea about why? I suppose javascript might be the
most-difficult-to-debug language on the earth. To really dig out the
reason of this strange behavor I must put <form> right above </body> and
remove other elements in the HTML source, once a half, and find out when
this behavor change. Such debuging would consume me A LOT of time.
I do program in many other languages, and I'd like to say javascript is
one of the most difficult to manage..
<form id="form_A"> xxxx </form>
This form is on one page in a page of a web application, it is the only
form on that page. on the end of the page in javascript:
document.getElementById("form_A").submit();
In the begining it works very well, after I restarted the browser and
did some small modification (I don't recall, but far from chaning that
form or script), it doesn't work. After some debuging it shows
document.getElementById("form_A") gets nothing, element with this ID
does not exist.
I tried so many debugging:
1) if change <form id="form_A"> to <div id="form_A"> then
document.getElementById("form_A") works
2) if move <form id="form_A"> to just below <body> then
document.getElementById("form_A") works
3) if move <form id="form_A"> to just above </body> then
document.getElementById("form_A") return nothing
4) if move <form id="form_A"> to random place in the webpage
document.getElementById("form_A") return nothing
5) if remove all other javascript on that page, only have the HTML and
one line of javascript document.getElementById("form_A"), except if we
put the form just below <body>, otherwise
document.getElementById("form_A") return nothing
6) use HTMLTIDY it shows only warning but no error
all above are tested on mozilla 1.7.8, I picked up random cases to test
on Opera 8.0 Final, same behavor as on moz.
in all above case, if document.getElementById("form_A") return nothing,
other means to retrive the <form> element all failed. Including
* addresssing the form by "name" attribute;
* getElementsByTagName('form');
* alert(fatherelement.innerHTML).
It just vanishes perfectly! E.g if I display html.innerHTML then in the
dialogue box the whole HTML source is displayed, PERFECTLY without the
<form>
Any idea about why? I suppose javascript might be the
most-difficult-to-debug language on the earth. To really dig out the
reason of this strange behavor I must put <form> right above </body> and
remove other elements in the HTML source, once a half, and find out when
this behavor change. Such debuging would consume me A LOT of time.
I do program in many other languages, and I'd like to say javascript is
one of the most difficult to manage..