Metachecker.net
|
TrafficChecker.net
|
RankChecker.net
Learn Java Script Today
|
Over 5000 Free Fonts
|
Tutorials
|
Javascript Forum
|
Other Javascript Resources
|
Cheat Sheet
JavaScript Basics
Inserting Javascript
Complete Tutorial
Advance DHTML Tutorial
Script archive
Advanced Tutorials
Alert Scripts
Animation
Audio
Background Effects
Banner Ads
Browser Window
Buttons
Button Forms
Calculcators
Calendars
Clocks & Dates
Cookies
Cursor Effects
DHMTL Games
DHTML Miscellaneous
Equivalents
Forms
Games
IE4+ Scripts
IE5+ Scripts
Image Effects
Image Miscellaneous
Links & Buttons
Math Related
Messages Miscellaneous
Miscellaneous
Mouse Tricks
Navigation
Page Details
Password Protection
Pulldown Menus
Random Stuff
Scrolling
Status Bar
Text Animation
User Detail
User Info
Window Control
Dragable elements
The image below will speak for itself:
Drag the cars above by clicking the mouse on them!
Insert into <HEAD>
<style> <!-- .drag{position:relative;cursor:hand} --> </style> <script language="JavaScript1.2"> <!-- /*Credit www.wsabstract.com*/ var dragapproved=false var z,x,y function move(){ if (event.button==1&&dragapproved){ z.style.pixelLeft=temp1+event.clientX-x z.style.pixelTop=temp2+event.clientY-y return false } } function drags(){ if (!document.all) return if (event.srcElement.className=="drag"){ dragapproved=true z=event.srcElement temp1=z.style.pixelLeft temp2=z.style.pixelTop x=event.clientX y=event.clientY document.onmousemove=move } } document.onmousedown=drags document.onmouseup=new Function("dragapproved=false") //--> </script>
Insert into <BODY>
<img src="test1.gif" class="drag"><br> <img src="test2.gif" class="drag"><br>
Other Options
Once the engine has been installed, enabling any element in a page to be dragable is a snap. Simply give the element a class="drag" declaration. Dragging image elements Assuming we have in front of us a page like this: <html> <head> <!--drag engine code here--> </head> <body> <img src="test.gif"><br> <img src="test2.gif"><br> <b>"Hi there</b> </body> </html> To apply drag-drop capabilities to the first two images above, do this: <html> <head> <!--drag engine code here--> </head> <body> <img src="test.gif" class="drag"><br> <img src="test2.gif" class="drag"><br> <h1><b>"Hi there</b></h1> </body> </html> The two images will now move when the mouse drags them. Dragging text elements What about text elements, you say? Well, the engine handles them just as well: <html> <body> <img src="test.gif"><br> <img src="test2.gif"><br> <h1><b class="drag">"Hi there</b></h1> </body> </html>