H
Howard Jess
[Submitted as a bug to Opera; posted here in hopes of finding an explanation?]
In Opera 8.01 (Linux; Build 1204) and in Opera 7.54 (Windows XP; Build 3865),
my form disappears from the HTML markup (below). To summarize:
1) In a <script> block in the <head> I create a form element (part of
object/feature/bug detection).
2) There's a <form> element defined in the <body>, with the id 'theForm'.
3) The onload function tries to access that form, and also counts the
total number of forms in the document. It fails to get a reference
to the form; the count is 0.
Black magic?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head><title>form</title><script type="text/javascript">
if (document.createElement) {
_obj = document.createElement('form');
alert('_obj: ' + _obj);
}
function olfunc() {
var f = document.getElementById('theForm');
var ftags = document.getElementsByTagName('form');
alert('f = ' + f + '\n' +
'# forms = ' + ftags.length);
}
window.onload = olfunc;
</script></head><body><div><form id="theForm" action=""><p>
text of a paragraph in theForm</p></form></div></body></html>
The alert boxes say:
_obj: [object HTMLFormElement]
and
f = null
# forms = 0
hj
In Opera 8.01 (Linux; Build 1204) and in Opera 7.54 (Windows XP; Build 3865),
my form disappears from the HTML markup (below). To summarize:
1) In a <script> block in the <head> I create a form element (part of
object/feature/bug detection).
2) There's a <form> element defined in the <body>, with the id 'theForm'.
3) The onload function tries to access that form, and also counts the
total number of forms in the document. It fails to get a reference
to the form; the count is 0.
Black magic?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head><title>form</title><script type="text/javascript">
if (document.createElement) {
_obj = document.createElement('form');
alert('_obj: ' + _obj);
}
function olfunc() {
var f = document.getElementById('theForm');
var ftags = document.getElementsByTagName('form');
alert('f = ' + f + '\n' +
'# forms = ' + ftags.length);
}
window.onload = olfunc;
</script></head><body><div><form id="theForm" action=""><p>
text of a paragraph in theForm</p></form></div></body></html>
The alert boxes say:
_obj: [object HTMLFormElement]
and
f = null
# forms = 0
hj