README.md

December 4, 2022 ยท View on GitHub

Dragging In Browser Using DHTML

Description

Sharing the information with fellow programmers

More Info

Submitted On
BySanjeev Kaushik
LevelAdvanced
User Rating3.5 (14 globes from 4 users)
Compatibility
Category.JS files
WorldJava
Archive File

Source Code

<html>
<head>
 <title>Dragging In browser</title>
<meta name="Keywords" content="Dragging in DHTML by Sanjeev Kaushik" />
<meta name="Description" content="Dragging in DHTML by Sanjeev Kaushik,HTML,CSS,JavaScript,DHTML" />
<script language=javascript>
function go(){
if (event.button!=1)
		return;
	mydiv = eval("document.all.my");
	temp1 = mydiv.style.posLeft;
	temp2 = mydiv.style.posTop;
	xpos = event.clientX;
	ypos = event.clientY;
	xoff = temp1-xpos;
	yoff = temp2-ypos;
	mydiv.onmousemove = mymove;
}
function mymove(){
if (event.button==1){
  		x = event.clientX + xoff
		y = event.clientY + yoff;
		 mydiv.style.pixelLeft = x;
		mydiv.style.pixelTop =y
		return false;
	}
}
</script>
</head>
<body>
<div title="press left button and drag" align=center onmousedown="go()" id="my" style="position:absolute;left:100;top:100;width:150;background-color:maroon;filter:alpha(style=3);cursor:hand">
<font color=yellow>Sanjeev Kaushik</font>
<!-- you can also add any image here -->
</div>
</body>
</html>