Moving DIVs?

Discussion in 'Javascript' started by Gernot Frisch, Apr 22, 2004.

  1. Hi,


    this is where the DIVs of a menu get created:
    <div id="menudivs" class="m' + this.container.id + 'l' + this.depth +
    'i">'
    + this.fields[0] + "</div>

    How do I loop through all of them and move them by "dx" horizontally.
    (I want to put this in a window.onresize event handler)

    Thank you,

    --
    -Gernot

    Post here, don't email. If you feel you have to mail, revert my
    forename from:

    ________________________________________
    Looking for a good game? Do it yourself!
    GLBasic - you can do
    www.GLBasic.com
    Gernot Frisch, Apr 22, 2004
    #1
    1. Advertising

  2. Gernot Frisch wrote:

    > this is where the DIVs of a menu get created:
    > <div id="menudivs" class="m' + this.container.id + 'l' + this.depth +
    > 'i">'
    > + this.fields[0] + "</div>
    >
    > How do I loop through all of them and move them by "dx" horizontally.


    RTFM. There are two ways:

    A) Move each "div" element. Obtain the collection of elements with
    document.getElementsByTagName() (W3C), document.all() (IE4+) or
    document.layers (NN4), then test against the className property
    of each element object.

    B) Change the value of the left property in the class selector
    (not in NS4 and Opera). Obtain the list of stylesheets for
    the document with document.styleSheets and the rules with
    the document.styleSheets[...].cssRules (Gecko) or the
    document.styleSheets[...].rules (IE) collection.

    > (I want to put this in a window.onresize event handler)


    Oh my. Use a proper stylesheet instead. What if client-side script
    support is restricted or disabled or the DOM does not support that at
    all? Thought about the user's system resources?


    PointedEars

    P.S.:
    is not a mailbox address ("A mailbox receives mail"):

    |
    | SMTP error from remote mailer after RCPT TO:<>:
    | host privacy.net [66.46.181.115]:
    | 550 relaying mail to privacy.net is not allowed

    Thus using it violates Internet/NetNews standards (RFCs 1036
    and 2822). Even if it would receive mail, the automated
    response described on the website would still disregard
    Usenet Netiquette. So people using privacy.net addresses
    are automatically killfiled by me from now on.
    See [en] <http://www.interhack.net/pubs/munging-harmful/>
    and/or [de] <http://gerlo.de/falsche-email-adressen.html>
    for details.

    P.P.S.: de.comp.lang.javascript exists.
    Thomas 'PointedEars' Lahn, May 3, 2004
    #2
    1. Advertising

  3. > RTFM. There are two ways:

    Sorry, I don't have TFM. Where do I get it?

    > A) Move each "div" element. Obtain the collection of elements with
    > document.getElementsByTagName() (W3C), document.all() (IE4+) or
    > document.layers (NN4), then test against the className property
    > of each element object.


    Er... OK. I think I understand.

    > B) Change the value of the left property in the class selector
    > (not in NS4 and Opera). Obtain the list of stylesheets for
    > the document with document.styleSheets and the rules with
    > the document.styleSheets[...].cssRules (Gecko) or the
    > document.styleSheets[...].rules (IE) collection.


    That's not X-browser compatible, right?

    > > (I want to put this in a window.onresize event handler)

    >
    > Oh my. Use a proper stylesheet instead. What if client-side script
    > support is restricted or disabled or the DOM does not support that

    at
    > all? Thought about the user's system resources?


    The onresize is triggered quite often, huh? Can you give me a link to
    this approach you suggested? I'm a complete idiot when it comes to
    JavaScript.

    > is not a mailbox address ("A mailbox receives mail"):


    Sorry, It's for spam-reasons. Don't mail, post here.
    -Geront
    Gernot Frisch, May 3, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rich
    Replies:
    0
    Views:
    719
  2. Igor Stroh

    Dragging & moving DIVs

    Igor Stroh, Sep 1, 2004, in forum: Javascript
    Replies:
    3
    Views:
    75
    J. J. Cale
    Sep 2, 2004
  3. 9.co.uk
    Replies:
    6
    Views:
    97
  4. Replies:
    1
    Views:
    149
    Laurent Bugnion [MVP]
    Feb 5, 2007
  5. maya
    Replies:
    4
    Views:
    239
Loading...

Share This Page