Thomas 'PointedEars' Lahn <cljs@PointedEars.de>:
> Gordon wrote:
> ^^^^^^
> Please use your full (real) name.
>
> > Context: I am using the most recent Firefox browser
> > on a Linux (Ubuntu 14.04) box. I am constructing a
> > page where, when the user clicks on a picture,
> > related pictures appear under it, pushing subsequent
> > material down.
>
> The proper term is â??documentâ?, not â??pageâ?.
>
> > [â?¦] In all five cases I use appendChild to attach the div
> > to the 'H' div. The divs then display in the same order.
> > (I would think they would display in reverse order,
>
> Unfounded.
>
> > since they are being successively appended to 'H', not
> > to the last appended, but they don't.)
>
> â??Appendâ? means â??to insert at the endâ? (cf. â??prependâ?).
It depends on what 'append' means in this particular
context. If we consider H as a node in a graph
....-H-... and appending A to H results in ...-H-A-...,
one might think subsequently appending B to H might
be expected to result in ...-H-B-A-..., B being placed
directly after H. But obviously other interpretations
are possible. (Here I am conflating assumptions
about the way the append takes place and the way
the result is subsequently displayed.)
> > While the page is up, if the user clicks on a link within
> > one of the five divs, say 'C', another set of divs is similarly
> > created, let us say 'c1', 'c2', 'c3', .... These I append
> > to div 'C'. I want them to appear below 'C' and before 'D',
> > but instead they display below 'E'.
>
> You must have appended them to 'H' instead.
So you seem to agree with my assumption above, that
the layout procedure reads the tree such that if I have appended
c1 to C, then I ought to observe the divs in the
order H, A, B, C, c1, c2, ..., cn, D, .... (For space
reasons the content of the divs will appear vertically,
and inserted material should push the material after it
in the tree downward. Hopefully.)
Historically, the makers of browsers and script
interpreters do not seem to have felt any obligation
to do things in any particular way, so for all I know
my assumption of depth-first left-to-right searching
or whatever it is could be indeed completely
unfounded in some cases. Hence my approach to this
temple of learning, wisdom, and practical experience.
>
> > My questions are (1) Why, if appending after 'H' works
> > as I expect, don't the other appendChild calls?
>
> Impossible to say, all crystal balls are under repair.
> But this Magic 8-ball here says: â??Concentrate and ask againâ?.
>
> > and
> > (2) How can I get the result I want?
>
> Well, you *could* try running three magic rounds around the larch at
> midnight when the moon is full.
>
> > Note: I don't want to do the work of locating these items on the
> > page by numerical coordinates, I want the browser to
> > do that work, so the divs will respond to possible
> > changes in the size for foregoing material. If
> > possible.
>
> The browser will do the right thing if you tell it right.
Well, that's the problem.
> > Thanks for any help or suggestions you can give.
>
> Talk is cheap. Show me the code.
> â??Linus Torvalds
>
> See also the FAQ.
There is a lot of other material in the code, making it
difficult to read as-is. If the problem persists I will
prepare a stripped-down version of it and post that.
Thanks for your help.