Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

phpmyadmin fehler rechte unerlaubte mischung, WWWXXXApc, lilo trying to map files from unnamed device 0x0000", Wwwxxxapc, CAM::PDF::Renderer::TextF Fragen, adodb.recordset error '800a0cc1', php save mails as eml, WWWXXXAPC, sqlexpress database file auto-creation error, sqlexpress database file auto-creation error

Links

XODOX
Impressum
Datenschutz

#1: Microsoft Madness while writting Web2 App !!

Posted on 2008-04-15 14:19:40 by JT

arghh.. I am writing a web app for real-time streaming of market data
(equities) and am implementing a quick getElementsById function as
needed; in gecko FF this is a walk with document.evaluate. In IE i am
using document.all (i presume this is the only efficient alternative
for IE, am i correct?)..

Anyway the madness is this:

var _sID = "501"; // some arbitrary ID which exists in the hierarchy.

var result1 = (typeof document.all[_sID]); //result1 = undefined

// However

for (var x in document.all)
{
if(x == _sID ) //this case is eventually hit (i.e equals true at a
given point)
result2 = document.all[x]; // result2 = is also undefined!!!!
}

Now why would IE say that result2 is undefined when that value was
returned in the enumeration.

Some debugging reveals that this problem only occurs with pure
numerical IDs!!! So pre-pending any market code with an arbitrary
string solves the problem!!! Truly i would love to know what the IE
team was thinking when they implemented this collection!!!

Any thoughts on this? Thank you.

Report this message

#2: Re: Microsoft Madness while writting Web2 App !!

Posted on 2008-04-15 15:00:16 by Andy Dingley

On 15 Apr, 13:19, JT <jamie.taleyark...@gmail.com> wrote:

> Some debugging reveals that this problem only occurs with pure
> numerical IDs!!!

If it doesn't begin with a letter (not a digit), then it can't be a
well-formed NAME or ID token, thus isn't well-formed to use in an
attribute (such as id) that is declared as being of type ID. If you
validated your HTML, you'd see this.
<http://www.w3.org/TR/html4/types.html#type-id>

This rarely causes a problem for the display of HTML, however it does
cause trouble (as you've seen) with getElementById() etc.

Report this message

#3: Re: Microsoft Madness while writting Web2 App !!

Posted on 2008-04-15 15:06:55 by lws4art

JT wrote:
> arghh.. I am writing a web app for real-time streaming of market data
> (equities) and am implementing a quick getElementsById function as
> needed; in gecko FF this is a walk with document.evaluate. In IE i am
> using document.all (i presume this is the only efficient alternative
> for IE, am i correct?)..
>
> Anyway the madness is this:
>
> var _sID = "501"; // some arbitrary ID which exists in the hierarchy.

<snip>

> Some debugging reveals that this problem only occurs with pure
> numerical IDs!!! So pre-pending any market code with an arbitrary
> string solves the problem!!! Truly i would love to know what the IE
> team was thinking when they implemented this collection!!!

Your debugging pointed you to your problem, but in this case it not IE's
fault, but the other way around

'ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
followed by any number of letters, digits ([0-9]), hyphens ("-"),
underscores ("_"), colons (":"), and periods (".").'

http:///www.w3.org/TR/html4/types.html#type-name

"5" is not a letter

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Report this message

#4: Re: Microsoft Madness while writting Web2 App !!

Posted on 2008-04-15 15:49:24 by Bergamot

JT wrote:
>
> am implementing a quick getElementsById function

I assume you mean getElementById (singular, not plural)

> In IE i am
> using document.all (i presume this is the only efficient alternative
> for IE, am i correct?)..

getElementById works in IE just fine. Have you tried it?

--
Berg

Report this message

#5: Re: Microsoft Madness while writting Web2 App !!

Posted on 2008-04-15 18:56:20 by Andy Dingley

On 15 Apr, 14:49, Bergamot <berga...@visi.com> wrote:
> JT wrote:
>
> > am implementing a quick getElementsById function
>
> I assume you mean getElementById (singular, not plural)

He wouldn't need to implement that.

Report this message

#6: Re: Microsoft Madness while writting Web2 App !!

Posted on 2008-04-17 09:11:21 by JT

On Apr 15, 6:00 pm, Andy Dingley <ding...@codesmiths.com> wrote:
> On 15 Apr, 13:19, JT <jamie.taleyark...@gmail.com> wrote:
>
> > Some debugging reveals that this problem only occurs with pure
> > numerical IDs!!!
>
> If it doesn't begin with a letter (not a digit), then it can't be a
> well-formed NAME or ID token, thus isn't well-formed to use in an
> attribute (such as id) that is declared as being of type ID. If you
> validated your HTML, you'd see this.
> <http://www.w3.org/TR/html4/types.html#type-id>
>
> This rarely causes a problem for the display of HTML, however it does
> cause trouble (as you've seen) with getElementById() etc.

OK i didn't realise that it was not good design to use pure numerical
values for ID. Thanks for pointing it out. I guess we seam to start
blaming microsoft for any problems we have, not good.. cheers.

Report this message

#7: Re: Microsoft Madness while writting Web2 App !!

Posted on 2008-04-17 09:13:04 by JT

On Apr 15, 6:49 pm, Bergamot <berga...@visi.com> wrote:
> JT wrote:
>
> > am implementing a quick getElementsById function
>
> I assume you mean getElementById (singular, not plural)
>
> > In IE i am
> > using document.all (i presume this is the only efficient alternative
> > for IE, am i correct?)..
>
> getElementById works in IE just fine. Have you tried it?
>
> --
> Berg

Nope i did mean getElementsById, getElementById only returns one
object irrespective of how many objects with the same ID exist. In
this case i may have the same market data appear in different DIV
elements and this just want to return an array of all Divs with that
ID; something getElementById will not do. cheers.

Report this message

#8: Re: Microsoft Madness while writting Web2 App !!

Posted on 2008-04-17 09:33:43 by Neredbojias

On 17 Apr 2008, JT <jamie.taleyarkhan@gmail.com> wrote:

> On Apr 15, 6:49 pm, Bergamot <berga...@visi.com> wrote:
>> JT wrote:
>>
>> > am implementing a quick getElementsById function
>>
>> I assume you mean getElementById (singular, not plural)
>>
>> > In IE i am
>> > using document.all (i presume this is the only efficient
>> > alternative for IE, am i correct?)..
>>
>> getElementById works in IE just fine. Have you tried it?
>>
>> --
>> Berg
>
> Nope i did mean getElementsById, getElementById only returns one
> object irrespective of how many objects with the same ID exist. In
> this case i may have the same market data appear in different DIV
> elements and this just want to return an array of all Divs with that
> ID; something getElementById will not do. cheers.

Say what? There ain't no "getElementsById", bro. Some say there _is_ a
"getElementsByName", but I've never used it so I can't elucidate
eclectically.

--
Neredbojias
http://www.neredbojias.com/
Great sights and sounds

Report this message

#9: Re: Microsoft Madness while writting Web2 App !!

Posted on 2008-04-17 14:40:49 by Bergamot

Neredbojias wrote:
>
> Say what? There ain't no "getElementsById", bro.

Um, he just explained he's writing his own function to get multiple
elements.

> Some say there _is_ a
> "getElementsByName"

Maybe you mean getElementsByTagName, which does work beautifully.

--
Berg

Report this message

#10: Re: Microsoft Madness while writting Web2 App !!

Posted on 2008-04-17 21:11:39 by Jeremy J Starcher

On Thu, 17 Apr 2008 00:13:04 -0700, JT wrote:

> Nope i did mean getElementsById, getElementById only returns one object
> irrespective of how many objects with the same ID exist. In this case i
> may have the same market data appear in different DIV elements and this
> just want to return an array of all Divs with that ID; something
> getElementById will not do. cheers.

HTML 4.01 strict requires that element ids be unique within the document,
though most (all?) browsers do not enforce that rule. Hence, there is no
get ElementsByID.

One common way to flag multiple elements is to give them multiple
classes. Then you can cycle through the elements you are after, see if
they belong to a certain class, then do your operations.

Sample code: (I didn't feel like tracking down the URL)

This code finds all tables in my document that have the class
'ruler' or 'tech' and sets up the table rows for mouse-over highlighting.


/*
tableruler()
written by Chris Heilmann for alistapart.
enables a rollover of rows for each table with the classname ...
*/

function tableruler()
{
if (document.getElementById && document.createTextNode)
{
var tables=document.getElementsByTagName('table');
for (var i=0;i<tables.length;i++)
{
if ((tables[i].className=='ruler') || (tables[i].className=='tech'))
{
var trs=tables[i].getElementsByTagName('tr');
for(var j=0;j<trs.length;j++)
{
if(trs[j].parentNode.nodeName=='TBODY' && trs[j].className=="")
{
trs[j].onmouseover=function(){this.className='ruled';return
false}
trs[j].onmouseout=function(){this.className='';return false}
}
}
}
}
}
}

Report this message

#11: Re: Microsoft Madness while writting Web2 App !!

Posted on 2008-04-17 22:44:50 by Neredbojias

On 17 Apr 2008, Neredbojias <me@http://www.neredbojias.com/_eml/fliam.php>
wrote:

>>> > am implementing a quick getElementsById function
>>>
>>> I assume you mean getElementById (singular, not plural)
>>>
>>> > In IE i am
>>> > using document.all (i presume this is the only efficient
>>> > alternative for IE, am i correct?)..
>>>
>>> getElementById works in IE just fine. Have you tried it?
>>>
>>> --
>>> Berg
>>
>> Nope i did mean getElementsById, getElementById only returns one
>> object irrespective of how many objects with the same ID exist. In
>> this case i may have the same market data appear in different DIV
>> elements and this just want to return an array of all Divs with that
>> ID; something getElementById will not do. cheers.
>
> Say what? There ain't no "getElementsById", bro. Some say there _is_ a
> "getElementsByName", but I've never used it so I can't elucidate
> eclectically.

Well, you may be correct, but "implementing" can have various nuances and a
quick reading of the original post shows no complete function termed
getElementsById(). Furthermore, I _still_ don't really understand the
question because only 1 instance of a particular id is valid in a document.

--
Neredbojias
http://www.neredbojias.com/
Great sights and sounds

Report this message

#12: Re: Microsoft Madness while writting Web2 App !!

Posted on 2008-04-17 22:52:51 by Neredbojias

On 17 Apr 2008, Bergamot <bergamot@visi.com> wrote:

> Neredbojias wrote:
>>
>> Say what? There ain't no "getElementsById", bro.
>
> Um, he just explained he's writing his own function to get multiple
> elements.

Well, you may be correct, but "implementing" can have various nuances and a
quick reading of the original post shows no completed function termed
getElementsById(). Furthermore, I _still_ don't really understand the
question because only 1 instance of a particular id is valid in a document.

>> Some say there _is_ a
>> "getElementsByName"
>
> Maybe you mean getElementsByTagName, which does work beautifully.

Actually, I saw in some Google reference a statement that
"getElementsByName" exists. Not saying the author's right, though, and
yes, I was really thinking of "getElementsByTagName".

--
Neredbojias
http://www.neredbojias.com/
Great sights and sounds

Report this message