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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change Div Image Based on Position Question

    Hi based on this script (http://www.twinhelix.com/javascript/dragresize/demo/) I wanted to know if it's possible for a div to change an image within it based on a certain x/y coordinate.

    For example if the div with the dog image here (http://tab-bot.com/drag_resize.htm) is moved to a certain point to the right, it would change to cat.jpg.

    Thanks so much

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,140
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    This is a tough one, I think. Explorer has a pair of proprietary objects, offsetX and offsetY which give the mouse coordinates for an event, relative to the srcElement. But unless you only care about IE, you'll need something cross-browser and this is an area where there has been a lot of inconsistency.

    See:- http://www.mattkruse.com/javascript/...sitionTest.php


    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

  • #3
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,520
    Thanks
    3
    Thanked 507 Times in 494 Posts
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #4
    Regular Coder
    Join Date
    Jul 2007
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cool, thank you for the links!


  •  

    Posting Permissions

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