Ok, I've seen some example code on this, and it seems rather crazy.
I don't understand why they make it so hard..
All you need to do is get the current top and left coordinates of the div right?(on mouseevent ofcourse) and then as the user "drags" the div change the top and left to the new ones as they drag.
I know about the javascript mousedown/up/click events, but where would I go to get an "api" on that kind of stuff.
even if your div is at first "position:static" you can just change it to absolute when the drag.
and then you could change up the position easily once you are able to get the coordinates.
Thanks,
Justin Fox [ January 27, 2008: Message edited by: Bear Bibeault ]
"floating divs" is ambiguous, but from your text I assume you're talking about drag-and-drop.
There are a lot of nuances to it -- why are you trying to implement this yourself when so many implementations already exist (Scriptaculous and jQuery UI, for example)?
I have a div I made that has a products images and descriptions, you can click on the thumbnails and go through the different angles of the product, and it looks like a "window".
But I want the user to be able to drag it around.
Besides, I rather do it myself, it would not only be really cool looking, but it would be self gratifying also.
I only need a nudge in the right direction, I believe I could figure it out. I just need to know where to look to find out what I need to use to get this working.
Essentially you need to capture mouse click and move events and adjust the positioning of the element accordingly. Be aware the such event handling is highly browser-dependent if you want it to work in more than one browser.
Personally, I prefer the jQuery way: [ January 26, 2008: Message edited by: Bear Bibeault ]
Like Eric said, jQuery is a JavaScript library (were you not around last week during the promotion?). Not sure where you got some sort of JSP connection.