#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Posts
    3
    Rep Power
    0

    javascript guru needed


    ok, i'm simply making a little slider selector thing, the code is here: http://physdept.carleton.edu/working-test-slider.html

    anyway, i would like to know if there is a simple way to make it work with the postion being relative instead of absolute. is there some way to get the absolut pixel position of an image dynamically in javascript? i'm kind of new to javascript.

    thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2001
    Location
    Toronto, Ontario, Canada
    Posts
    631
    Rep Power
    14
    Whats the advantage of having it relative? The way it is is fine... change the 'return true' to 'return false' in the mouseMove() function. If it doesnt work, change it back. That should get rid of being able to highlight areas of the document while you're dragging the dropper.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Posts
    3
    Rep Power
    0
    thanks for the mouse move tip, that woked...

    the reason i want the postion to be relative is because i have a page with some graphs that can be different sizes and the position of the slider will not always be the same. if there's no way to do it with the position being relative that's fine but i just want to make sure i can't do it with the slider first.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2001
    Location
    Toronto, Ontario, Canada
    Posts
    631
    Rep Power
    14
    Change the position:absolute; property for ALL the divs to position:relative;

    Add:
    left:#;top#;

    That will give you a # of pixels offset to the div's static position.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Posts
    3
    Rep Power
    0
    thanks for the suggestion but i've already tried that. the problem happens when i do something like this:

    domRed.xpos = parseInt(domRed.left);

    this then takes the left of red (be it relative or absolute) and assumes it's an absolute position. this is my problem, maybe i just haven't stated my question clearly enough before, for that i am sorry.

    i'm just wondering if there is a way in javascript to get the absolute position of an image on a page after i have placed the div as relative...if you can't do that would there be a way to make my slider code respect the relative positions of my divs?

    thanks for all your help so far
    Last edited by G-funk; August 12th, 2001 at 11:52 PM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2001
    Location
    Toronto, Ontario, Canada
    Posts
    631
    Rep Power
    14
    You could put the image in a layer, and with javascript, use absolute positioning to position the slider.

    This is for IE only:
    <script language="javascript">
    function position() {
    document.all["div2"].style.top=document.all["div1"].style.top+document.all["div1"].style.height+50;
    }
    </script>

    That would give you 50px between the image and the slider div.

IMN logo majestic logo threadwatch logo seochat tools logo