473,688 Members | 3,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

element.childre n has no properties (mozilla only)

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.a spx" 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(ev entTarget, eventArgument) {
if (!theForm.onsub mit || (theForm.onsubm it() != false)) {
theForm.__EVENT TARGET.value = eventTarget;
theForm.__EVENT ARGUMENT.value = eventArgument;
theForm.submit( );
}
}
// -->
</script>

<select name="ddl" id="ddl">
<option value="hi">hi</option>
<option value="there">t here</option>
</select>

...BLAH BLAH BLAH

...a bunch of anchors with "javascript :" hrefs.

<script type="text/javascript">
<!--
var pageUrl='/Test2.aspx'; // localhost
WebForm_InitCal lback(); // <-------- Error in here
...more js
-->
</script>
</form>

Javascript causing error:

function WebForm_InitCal lback() {
var count = theForm.element s.length;
var element;
for (var i = 0; i < count; i++) {
element = theForm.element s[i];
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 )) {
__theFormPostDa ta += element.name + "=" +
WebForm_EncodeC allback(element .value) + "&";
}
}
else if (tagName == "select") {

// ***ERROR***
var selectCount = element.childre n.length; // <--
// ***ERROR***

for (var j = 0; j < selectCount; j++) {
var selectChild = element.childre n[j];
if ((selectChild.t agName.toLowerC ase() == "option")
&& (selectChild.se lected == true)) {
__theFormPostDa ta += element.name + "=" +
WebForm_EncodeC allback(selectC hild.value) + "&";
}
}
}
else if (tagName == "textarea") {
__theFormPostDa ta += element.name + "=" +
WebForm_EncodeC allback(element .value) + "&";
}
}
}

This clears IE fine, but FireFox 1.0.4 tosses the error

Error: element.childre n has no properties
Source File: ...

Does anyone know if there is something special about FireFox's "select"
element.childre n 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
Jul 23 '05 #1
6 13365


Luke Dalessandro wrote:

else if (tagName == "select") {

// ***ERROR***
var selectCount = element.childre n.length; // <--
// ***ERROR***


children is part of the IE DOM since IE 4 but it is not part of the W3C
DOM that Mozilla implements. The closest in that object model is
childNodes which contains all child nodes (including text nodes) while
children contains all child elements.

As for that code I would simply loop through element.options once it has
been established that element is a select element.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Martin,

Thanks for the pointer... unfortunately, I have no control over the
code. The script is autogenerated through a call to a predetermined
handler in .NET (ie, the framework automatically add a

<script
src="/WebResource.axd ?d=MSFJ4SIWhD3c injlZxIy4w2&amp ;t=632546115913 125000"
type="text/javascript"></script>

tag when rendering the page.

Looks like MS is continuing to write broken code. sigh...

Luke

Martin Honnen wrote:


Luke Dalessandro wrote:

else if (tagName == "select") {

// ***ERROR***
var selectCount = element.childre n.length; // <--
// ***ERROR***

children is part of the IE DOM since IE 4 but it is not part of the W3C
DOM that Mozilla implements. The closest in that object model is
childNodes which contains all child nodes (including text nodes) while
children contains all child elements.

As for that code I would simply loop through element.options once it has
been established that element is a select element.

Jul 23 '05 #3
Hi Luke,

I use this piece of code to correct the problem:
<code>
if (typeof Node != 'undefined') {
if (typeof Node.children == 'undefined') {
eval('Node.prot otype.children getter = function() {return
this.childNodes ;}');
}
}
</code>
And wait until MS fixes the problem.

Diego

"Luke Dalessandro" <us****@luked.n et> schreef in bericht
news:V5******** ********@news01 .roc.ny...
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.a spx" 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(ev entTarget, eventArgument) {
if (!theForm.onsub mit || (theForm.onsubm it() != false)) {
theForm.__EVENT TARGET.value = eventTarget;
theForm.__EVENT ARGUMENT.value = eventArgument;
theForm.submit( );
}
}
// -->
</script>

<select name="ddl" id="ddl">
<option value="hi">hi</option>
<option value="there">t here</option>
</select>

...BLAH BLAH BLAH

...a bunch of anchors with "javascript :" hrefs.

<script type="text/javascript">
<!--
var pageUrl='/Test2.aspx'; // localhost
WebForm_InitCal lback(); // <-------- Error in here
...more js
-->
</script>
</form>

Javascript causing error:

function WebForm_InitCal lback() {
var count = theForm.element s.length;
var element;
for (var i = 0; i < count; i++) {
element = theForm.element s[i];
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 )) {
__theFormPostDa ta += element.name + "=" +
WebForm_EncodeC allback(element .value) + "&";
}
}
else if (tagName == "select") {

// ***ERROR***
var selectCount = element.childre n.length; // <--
// ***ERROR***

for (var j = 0; j < selectCount; j++) {
var selectChild = element.childre n[j];
if ((selectChild.t agName.toLowerC ase() == "option")
&& (selectChild.se lected == true)) {
__theFormPostDa ta += element.name + "=" +
WebForm_EncodeC allback(selectC hild.value) + "&";
}
}
}
else if (tagName == "textarea") {
__theFormPostDa ta += element.name + "=" +
WebForm_EncodeC allback(element .value) + "&";
}
}
}

This clears IE fine, but FireFox 1.0.4 tosses the error

Error: element.childre n has no properties
Source File: ...

Does anyone know if there is something special about FireFox's "select"
element.childre n 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

Jul 23 '05 #4
I had the same problem myself. You can work around the problem by
adding a call to a function like the one I've written below. I
basically just added a check to see if the children property exist.

If you have a <asp:button> on your page just do this in the codebehind:

mybutton.Attrib utes.Add( "onclick", "PrepareForPost Back();" );

This should ensure it would run the Prepare function before doing the
actual postback.

Regards,
Mikael Svenson
C# Developer
-JAVASCRIPT--

function PrepareForPostB ack()
{
try { WebForm_InitCal lback();}
catch( e )
{
WebForm_InitCal lback_Mozilla() ;
}
}

function WebForm_InitCal lback_Mozilla() {
var count = theForm.element s.length;
var element;
for (var i = 0; i < count; i++) {
element = theForm.element s[i];
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 )) {
__theFormPostDa ta += element.name + "=" +
WebForm_EncodeC allback(element .value) + "&";
}
}
else if (tagName == "select") {
var children;
if( typeof element.childre n == 'undefined' ) {
<!-- We are using mozilla -->
children = element.childNo des;
}
else
{
<!-- we are using IE -->
children = element.childre n;
}

var selectCount = children.length ;
for (var j = 0; j < selectCount; j++) {
var selectChild = children[j];
if ((selectChild.t agName.toLowerC ase() == "option") &&
(selectChild.se lected == true)) {
__theFormPostDa ta += element.name + "=" +
WebForm_EncodeC allback(selectC hild.value) + "&";
}
}
}
else if (tagName == "textarea") {
__theFormPostDa ta += element.name + "=" +
WebForm_EncodeC allback(element .value) + "&";
}
}
}

Diego wrote:
Hi Luke,

I use this piece of code to correct the problem:
<code>
if (typeof Node != 'undefined') {
if (typeof Node.children == 'undefined') {
eval('Node.prot otype.children getter = function() {return
this.childNodes ;}');
}
}
</code>
And wait until MS fixes the problem.

Diego

"Luke Dalessandro" <us****@luked.n et> schreef in bericht
news:V5******** ********@news01 .roc.ny...
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.a spx" 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(ev entTarget, eventArgument) {
if (!theForm.onsub mit || (theForm.onsubm it() != false)) {
theForm.__EVENT TARGET.value = eventTarget;
theForm.__EVENT ARGUMENT.value = eventArgument;
theForm.submit( );
}
}
// -->
</script>

<select name="ddl" id="ddl">
<option value="hi">hi</option>
<option value="there">t here</option>
</select>

...BLAH BLAH BLAH

...a bunch of anchors with "javascript :" hrefs.

<script type="text/javascript">
<!--
var pageUrl='/Test2.aspx'; // localhost
WebForm_InitCal lback(); // <-------- Error in here
...more js
-->
</script>
</form>

Javascript causing error:

function WebForm_InitCal lback() {
var count = theForm.element s.length;
var element;
for (var i = 0; i < count; i++) {
element = theForm.element s[i];
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 )) {
__theFormPostDa ta += element.name + "=" +
WebForm_EncodeC allback(element .value) + "&";
}
}
else if (tagName == "select") {

// ***ERROR***
var selectCount = element.childre n.length; // <--
// ***ERROR***

for (var j = 0; j < selectCount; j++) {
var selectChild = element.childre n[j];
if ((selectChild.t agName.toLowerC ase() == "option")
&& (selectChild.se lected == true)) {
__theFormPostDa ta += element.name + "=" +
WebForm_EncodeC allback(selectC hild.value) + "&";
}
}
}
else if (tagName == "textarea") {
__theFormPostDa ta += element.name + "=" +
WebForm_EncodeC allback(element .value) + "&";
}
}
}

This clears IE fine, but FireFox 1.0.4 tosses the error

Error: element.childre n has no properties
Source File: ...

Does anyone know if there is something special about FireFox's "select"
element.childre n 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


Jul 23 '05 #5
Forgot to mention that you have to do

_theFormPostDat a = '';

before running WebForm_InitCal lback, or put it as the first line. If
not you will get double values.

Regards,
Mikael Svenson
C# developer
Jul 23 '05 #6
ASM
Luke Dalessandro wrote:
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.a spx" 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(ev entTarget, eventArgument) {
if (!theForm.onsub mit || (theForm.onsubm it() != false)) {
theForm.__EVENT TARGET.value = eventTarget;
theForm.target = enventTarget
theForm.__EVENT ARGUMENT.value = eventArgument;
theForm.submit( );
}
}
// -->
</script>

<select name="ddl" id="ddl">
<option value="hi">hi</option>
<option value="there">t here</option>
</select>

...BLAH BLAH BLAH

...a bunch of anchors with "javascript :" hrefs.

<script type="text/javascript">
<!--
var pageUrl='/Test2.aspx'; // localhost
WebForm_InitCal lback(); // <-------- Error in here
...more js
-->
</script>
</form>

Javascript causing error:

function WebForm_InitCal lback() {
and with some less lines and calabistic words ?

var __theFormPostDa ta = ''; // if absolutly needed

function WebForm_InitCal lback() {
// would prefer to set theForm here
// theForm = document.forms[0];
var F = theForm; // hope theForm was ok ! ?
var D = '';
for(var i=0;i<F.length; i++) {
if(F[i].tagName.toLowe rCase()=='selec t') {
if(F[i].selectedIndex! =0)
D += F[i].name+'='+F[i].options[F[i].selectedIndex].value+'&';
}
if(F[i].tagName.toLowe rCase()=='texta rea')
if(F[i].value!='')
D += F[i].name+'='+escap e(F[i].value)+'&';
var e = F[i].type.toLowerCa se();
if((e=='text'|| e=='password')& &e.value!='' ||
(e=='checkbox'| |e=='radio')&&F[i].checked)
D += F[i].name+'='+escap e(F[i].value)+'&';
}
if(D=='') alert('Form empty');
else D = D.substring(0,D .length-1)
__theFormPostDa ta = D;
}
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.


if it works like that : No, thank you very very much
--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9208
by: Greg Brunet | last post by:
In puzzling over classes, I'm wondering if classes can have read-only static properties? I certainly seem to be able to do create static properties like this: class C(object): count = 0 def __init__(self,s): C.count += 1 self.Name = s
9
2197
by: Paul Moore | last post by:
I have a class with a read-only attribute, and I want to add a unit test to ensure that it really *is* read-only. I can do this as def test_readonly(self): """Value and multiplier must be readonly""" try: self.combat.value = 1 self.fail("Value is not read only") except AttributeError: pass
1
1182
by: cwj | last post by:
I have a form where you first select a state. The next step is to choose a county. Since I don't know what counties to show until the state is selected I am building the county menu with innerHTML. I use PHP to build the if statements when the page is first loaded. When the person selects a State the onChange triggers a fundtion that looks to see the value of what was slected then goes through a list of if statements to decide which...
13
3790
by: Julia Peterwitz | last post by:
I have a function that works with explorer but not with netscape. The problem is the function at line 5. 1 fSetSelectedDay(myElement){ 2 /* 3 ... 4 */ 5 var elementText = eval(myElement.children.innerText); 6 /*
8
2932
by: Nicolás Lichtmaier | last post by:
Hi, some time ago I've written an article about this issue. It explain some differences in Explorer's and Mozilla's JavaScript/DOM. It has recently changed its URL, This is the new one: http://www.reloco.com.ar/mozilla/compat.html Bye! PS: I hope it's useful to someone. I would appreciate any comments and suggestions!
5
2219
by: Dan Novak | last post by:
Hello, I'm trying to apply different backgrounds to a page based on the BODY element class. It's working on some browsers but not on others. I've searched Google and the groups, pored through my trusty O'Reilly books, but I can't find anything that suggests this isn't valid. I cut down the stylesheet and the page to the bare minimum, but the difference still appears.
8
1688
by: Doug Lerner | last post by:
I have this snippet of client side code running: var makeField = document.forms; alert("makeFieldName name,length,type=" + makeFieldName + ", " + makeField.name + "," + makeField.length + "," + makeField.type); The alert is just in there for debugging.
0
8590
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8782
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7621
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5807
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4321
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2215
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.