Tue Dec 02, 2008 1:56 am
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Drag and drop in website using javascript</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="drag.js"></script>
</head>
<body>
<div id="container">
<div id="info">Start drag process...</div>
<div id="square" style="position: relative; width: 60px; height: 60px; background:#990033; border: 2px solid #3399CC;"></div>
<script type="text/javascript">
function begin (element, x, y) {
var s = '#' + element.id + ' (begin drag)' + ' x:' + x + ', y:' + y;
updateInfo(s);
}
function drag (element, x, y) {
var s = '#' + element.id + ' (dragging)' + ' x:' + x + ', y:' + y;
updateInfo(s);
}
function end (element, x, y) {
var s = '#' + element.id + ' (end drag)' + ' x:' + x + ', y:' + y;
updateInfo(s);
}
function updateInfo(s) {
document.getElementById('info').innerHTML = s;
}
var square = DragHandler.attach(document.getElementById('square'));
square.dragBegin = begin;
square.drag = drag;
square.dragEnd = end;
</script>
</div>
</body>
</html>
Thu May 14, 2009 11:24 am
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.