L
Luke Dalessandro
I'm not sure if this is the correct forum for platform specific
(Mozilla/Firefox) javascript problems, so just shout and point me to the
correct newsgroup if I'm being bad.
Here's the deal...
html file (generated using .NET 2.0 beta2):
<form method="post" action="Test2.aspx" id="form1">
<div>
<input type="hidden" ... />
<input type="hidden" ... />
<input type="hidden" ... />
<input type="hidden" ... />
<input type="hidden" ... />
<input type="hidden" ... />
</div>
<script type="text/javascript">
<!--
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</script>
<select name="ddl" id="ddl">
<option value="hi">hi</option>
<option value="there">there</option>
</select>
...BLAH BLAH BLAH
...a bunch of anchors with "javascript:" hrefs.
<script type="text/javascript">
<!--
var pageUrl='/Test2.aspx'; // localhost
WebForm_InitCallback(); // <-------- Error in here
...more js
-->
</script>
</form>
Javascript causing error:
function WebForm_InitCallback() {
var count = theForm.elements.length;
var element;
for (var i = 0; i < count; i++) {
element = theForm.elements;
var tagName = element.tagName.toLowerCase();
if (tagName == "input") {
var type = element.type;
if (type == "text" || type == "hidden" || type ==
"password" ||
((type == "checkbox" || type == "radio") &&
element.checked)) {
__theFormPostData += element.name + "=" +
WebForm_EncodeCallback(element.value) + "&";
}
}
else if (tagName == "select") {
// ***ERROR***
var selectCount = element.children.length; // <--
// ***ERROR***
for (var j = 0; j < selectCount; j++) {
var selectChild = element.children[j];
if ((selectChild.tagName.toLowerCase() == "option")
&& (selectChild.selected == true)) {
__theFormPostData += element.name + "=" +
WebForm_EncodeCallback(selectChild.value) + "&";
}
}
}
else if (tagName == "textarea") {
__theFormPostData += element.name + "=" +
WebForm_EncodeCallback(element.value) + "&";
}
}
}
This clears IE fine, but FireFox 1.0.4 tosses the error
Error: element.children has no properties
Source File: ...
Does anyone know if there is something special about FireFox's "select"
element.children property that would cause this?
As a background, this code is autogenerated by ASP.NET in conjunction
with the TreeView control when it is set to use out-of-band callbacks to
populate TreeNodes... I can provide a live demo if you contact me directly.
Thanks in advance,
Luke Dalessandro
(Mozilla/Firefox) javascript problems, so just shout and point me to the
correct newsgroup if I'm being bad.
Here's the deal...
html file (generated using .NET 2.0 beta2):
<form method="post" action="Test2.aspx" id="form1">
<div>
<input type="hidden" ... />
<input type="hidden" ... />
<input type="hidden" ... />
<input type="hidden" ... />
<input type="hidden" ... />
<input type="hidden" ... />
</div>
<script type="text/javascript">
<!--
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</script>
<select name="ddl" id="ddl">
<option value="hi">hi</option>
<option value="there">there</option>
</select>
...BLAH BLAH BLAH
...a bunch of anchors with "javascript:" hrefs.
<script type="text/javascript">
<!--
var pageUrl='/Test2.aspx'; // localhost
WebForm_InitCallback(); // <-------- Error in here
...more js
-->
</script>
</form>
Javascript causing error:
function WebForm_InitCallback() {
var count = theForm.elements.length;
var element;
for (var i = 0; i < count; i++) {
element = theForm.elements;
var tagName = element.tagName.toLowerCase();
if (tagName == "input") {
var type = element.type;
if (type == "text" || type == "hidden" || type ==
"password" ||
((type == "checkbox" || type == "radio") &&
element.checked)) {
__theFormPostData += element.name + "=" +
WebForm_EncodeCallback(element.value) + "&";
}
}
else if (tagName == "select") {
// ***ERROR***
var selectCount = element.children.length; // <--
// ***ERROR***
for (var j = 0; j < selectCount; j++) {
var selectChild = element.children[j];
if ((selectChild.tagName.toLowerCase() == "option")
&& (selectChild.selected == true)) {
__theFormPostData += element.name + "=" +
WebForm_EncodeCallback(selectChild.value) + "&";
}
}
}
else if (tagName == "textarea") {
__theFormPostData += element.name + "=" +
WebForm_EncodeCallback(element.value) + "&";
}
}
}
This clears IE fine, but FireFox 1.0.4 tosses the error
Error: element.children has no properties
Source File: ...
Does anyone know if there is something special about FireFox's "select"
element.children property that would cause this?
As a background, this code is autogenerated by ASP.NET in conjunction
with the TreeView control when it is set to use out-of-band callbacks to
populate TreeNodes... I can provide a live demo if you contact me directly.
Thanks in advance,
Luke Dalessandro