Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    createElement('div') in a random location

    Hello,

    I am looking to do the following for a netArt project and can't figure out if it is possible. My instructor suggested I post my question here.

    The goal is to have a location on my webpage that if you click it, images of little cartoon children will pop up within the same browser window at random locations. I figured it had something to do with creating a new layer and placing an image within it but can't quite deciper if and how this is possible.

    I assume it has something to do with createElement('div') but can find nothing on being able to place these layers randomly.

    Is it possible? Is there a better way?

    Thanks for any info provided,

    michael

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    To place an element, set style properties ('position', 'left', and 'top').

    To set left & top randomly, use a couple of Math object methods (floor, random).

    To keep the element inside of the visible area, subtract element dimension properties (such as offsetWidth|offsetHeight from the body's dimensions), and use that in the equation...
    *this message will self destruct in n-seconds*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •