Home Advanced Code Drag Images

Drag Images

E-mail Print PDF
This code works great for puzzles or image makers.

Place this in the head of your page:

Code:
<style>
 <!--
 .
drag{position:relative;cursor:hand}
 -->
 </
style>
 <
script language="JavaScript1.2">
 <!--
 
 
//Generic Drag Script- © Dynamic Drive (www.dynamicdrive.com)
 //For full source code and terms of usage,
 //visit http://www.dynamicdrive.com
 
 
var ie=document.all
 
var ns6=document.getElementById&&!document.all
 
 
var dragapproved=false
 
var z,x,y
 
 
function move(e){
 if (
dragapproved){
 
z.style.left=ns6temp1+e.clientX-xtemp1+event.clientX-x
 z
.style.top=ns6temp2+e.clientY-temp2+event.clientY-y
 
return false
 
}
 }
 
 function 
drags(e){
 if (!
ie&&!ns6)
 return
 var 
firedobj=ns6e.target event.srcElement
 
var topelement=ns6"HTML" "BODY"
 
 
while (firedobj.tagName!=topelement&&firedobj.className!="drag"){
 
firedobj=ns6firedobj.parentNode firedobj.parentElement
 
}
 
 if (
firedobj.className=="drag"){
 
dragapproved=true
 z
=firedobj
 temp1
=parseInt(z.style.left+0)
 
temp2=parseInt(z.style.top+0)
 
x=ns6e.clientXevent.clientX
 y
=ns6e.clientYevent.clientY
 document
.onmousemove=move
 
return false
 
}
 }
 
document.onmousedown=drags
 document
.onmouseup=new Function("dragapproved=false")
 
//-->
 
</script> 
Use this code to link your images you would like to be draggable:

Code:
<img src="URLOFIMAGE" class="drag">

 

Domain Names

Sample image .com .info
.mobi .net
.org .tv .us
.biz .ws .name
.am .at .be .cc .cn .de .eu
.fm .jobs .jp .ms .nu .nz
.tc .tw .uk .vg .ASIA .ME

Website Hosting

Sample image We're the affordable, reliable place to host your site. And unlike the competition, there's no set up fee and no annual commitment.

24/7 Support

Sample image Our highly trained, courteous support staff is waiting to help. We'll resolve any issue to your complete satisfaction.