...

View Full Version : Change Div Image Based on Position Question



theflyingminstr
07-15-2009, 09:03 AM
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

Philip M
07-15-2009, 09:15 AM
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/ObjectPositionTest.php


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

vwphillips
07-15-2009, 12:48 PM
http://www.webdeveloper.com/forum/showthread.php?t=213072

theflyingminstr
07-15-2009, 03:18 PM
Cool, thank you for the links!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum