PDA

View Full Version : جابجا کردن عکس روی صفحه وب توسط کاربر



nasr
چهارشنبه 06 خرداد 1383, 19:05 عصر
سلام
با این کد کاربر می تواند یه عکس را روی صفحه وب جابجا کند


<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<script language="JavaScript">
<!--
var curElement;
function doMouseMove() {

var newleft=0, newTop = 0
if ((event.button==1) && (curElement!=null)) {

newleft=event.clientX-document.all.OuterDiv.offsetLeft-
(curElement.offsetWidth/2)
if (newleft<0) newleft=0
curElement.style.pixelLeft= newleft
newtop=event.clientY -document.all.OuterDiv.offsetTop-
(curElement.offsetHeight/2)
if (newtop<0) newtop=0
curElement.style.pixelTop= newtop
event.returnValue = false
event.cancelBubble = true
}
}

function doDragStart() {
// Don't do default drag operation.
if ("IMG"==event.srcElement.tagName)
event.returnValue=false;
}

function doMouseDown() {
if ((event.button==1) && (event.srcElement.tagName=="IMG")) curElement =
event.srcElement

}


document.ondragstart = doDragStart;
document.onmousedown = doMouseDown;
document.onmousemove = doMouseMove;
document.onmouseup = new Function("curElement=null")
//-->
</script>
<body>

<div id=OuterDiv style="position:relative;width:100%;height:300px">
<img id="Pic1" style="position:relative;top: 100;left: 30;cursor: hand;Z-INDEX: 3;"
src="file:///C:/WINDOWS/BACKGRND.GIF" border=0 alt="something" width="84" height="64">
</div>
</body>

</html> :wink: