danke für deine Antwort nur wie binde ich das jetzt in mein script ein??
hier mal mein script was ich bis jetzt habe
<html>
<head>
<title> Bild verändern </title>
<script language="javascript">
lastActionState='';
lastMouseX=0;
lastMouseY=0;
richtung=0;
function changeSizeStart(ev) {
lastActionState='move';
htmlElem=((ev.target) ? ev.target : ev.srcElement);
window.status=richtung;
}
function changeSizeEnd(ev) {
lastActionState='';
}
function mouseDownBody(ev) {
if (lastActionState=='move') {
lastMouseX=((ev.screenX) ? ev.screenX : ev.clientX) + document.body.offsetLeft;
lastMouseY=((ev.screenY) ? ev.screenY : ev.clientY) + document.body.offsetTop;
}
}
function mouseUpBody(ev) {
lastActionState='';
}
function mouseMoveBody(ev) {
var htmlImg;
var re=/px/g;
var re1=/pt/g;
if (lastActionState=='') {
// berechne Cursor-Type;
htmlImg=((ev.target) ? ev.target : ev.srcElement);
if (htmlImg.id!='img_sizeChange') return;
posX=((ev.layerX) ? ev.layerX : ev.offsetX);
posY=((ev.layerY) ? ev.layerY : ev.offsetY);
window.status= posX + '/' + posY;
imgWidth=htmlImg.style['width'].replace(re,'')-0;
imgHeight=htmlImg.style['height'].replace(re,'')-0;
drittelX=Math.floor((posX*3)/imgWidth);
drittelY=Math.floor((posY*3)/imgHeight);
if ((drittelY==0) && (drittelX==0)) htmlImg.style['cursor']='nw-resize';
if ((drittelY==0) && (drittelX==1)) htmlImg.style['cursor']='n-resize';
if ((drittelY==0) && (drittelX==2)) htmlImg.style['cursor']='ne-resize';
if ((drittelY==1) && (drittelX==0)) htmlImg.style['cursor']='w-resize';
if ((drittelY==1) && (drittelX==1)) htmlImg.style['cursor']='move';
if ((drittelY==1) && (drittelX==2)) htmlImg.style['cursor']='e-resize';
if ((drittelY==2) && (drittelX==0)) htmlImg.style['cursor']='sw-resize';
if ((drittelY==2) && (drittelX==1)) htmlImg.style['cursor']='s-resize';
if ((drittelY==2) && (drittelX==2)) htmlImg.style['cursor']='se-resize';
richtung=drittelY*3+drittelX+1;
window.status= posX + '/' + posY + ':' + imgWidth + '/' + imgHeight + ':' + drittelX + '/' + drittelY + ':' + richtung;
}
if (lastActionState=='move') {
newMouseX=((ev.screenX) ? ev.screenX : ev.clientX) + document.body.offsetLeft;
newMouseY=((ev.screenY) ? ev.screenY : ev.clientY) + document.body.offsetTop;
window.status=newMouseX + '/' + newMouseY;
if (richtung==1) {
diffX=newMouseY-lastMouseY;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' - diffX;
htmlImg.style['top']=htmlImg.style['top'].replace(re,'').replace(re1,'')-0 + diffX;
window.status=htmlImg.style['top'];
}
if (richtung==1) {
diffX=newMouseX-lastMouseX;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' + diffX;
htmlImg.style['left']=htmlImg.style['left'].replace(re,'').replace(re1,'')-0 + diffX;
window.status=htmlImg.style['left'];
}
if (richtung==2) {
diffX=newMouseY-lastMouseY;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' + diffX;
htmlImg.style['height']=htmlImg.style['height'].replace(re,'').replace(re1,'')-0 + diffX;
window.status=htmlImg.style['height'];
}
if (richtung==3) {
diffX=newMouseY-lastMouseY;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' + diffX;
htmlImg.style['height']=htmlImg.style['height'].replace(re,'').replace(re1,'')-0 - diffX;
window.status=htmlImg.style['height'];
}
if (richtung==3) {
diffX=newMouseX-lastMouseX;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' + diffX;
htmlImg.style['width']=htmlImg.style['width'].replace(re,'')-0 + diffX;
window.status=htmlImg.style['width'];
}
if (richtung==4) {
diffX=newMouseX-lastMouseX;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' + diffX;
htmlImg.style['left']=htmlImg.style['left'].replace(re,'').replace(re1,'')-0 - diffX;
window.status=htmlImg.style['left'];
ziehenachlinks(event)
}
if (richtung==5) {
diffX=newMouseY-lastMouseY;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' + diffX;
htmlImg.style['top']=htmlImg.style['top'].replace(re,'').replace(re1,'')-0 + diffX;
window.status=htmlImg.style['top'];
}
if (richtung==5) {
diffX=newMouseX-lastMouseX;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' + diffX;
htmlImg.style['left']=htmlImg.style['left'].replace(re,'').replace(re1,'')-0 + diffX;
window.status=htmlImg.style['left'];
}
if (richtung==6) {
diffX=newMouseX-lastMouseX;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' + diffX;
htmlImg.style['width']=htmlImg.style['width'].replace(re,'')-0 + diffX;
window.status=htmlImg.style['width'];
}
if (richtung==7) {
diffX=newMouseY-lastMouseY;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' + diffX;
htmlImg.style['height']=htmlImg.style['height'].replace(re,'').replace(re1,'')-0 + diffX;
window.status=htmlImg.style['height'];
}
if (richtung==7) {
diffX=newMouseX-lastMouseX;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' + diffX;
htmlImg.style['width']=htmlImg.style['width'].replace(re,'')-0 - diffX;
window.status=htmlImg.style['width'];
}
if (richtung==8) {
diffX=newMouseY-lastMouseY;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' + diffX;
htmlImg.style['height']=htmlImg.style['height'].replace(re,'')-0 + diffX;
window.status=htmlImg.style['height'];
}
if (richtung==9) {
diffX=newMouseY-lastMouseY;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' + diffX;
htmlImg.style['height']=htmlImg.style['height'].replace(re,'')-0 + diffX;
window.status=htmlImg.style['height'];
}
if (richtung==9) {
diffX=newMouseX-lastMouseX;
htmlImg=document.getElementById('img_sizeChange');
window.status='schiebe: ' + diffX;
htmlImg.style['width']=htmlImg.style['width'].replace(re,'')-0 + diffX;
window.status=htmlImg.style['width'];
}
lastMouseX=newMouseX;
lastMouseY=newMouseY;
}
}
</script>
</head>
<body width="800px" height="800px" onMouseDown="mouseDownBody(event)" onMouseUp="mouseUpBody(event)" onMouseMove="mouseMoveBody(event)">
<img id="img_sizeChange" src="sizeChange.gif" onmouseDown="changeSizeStart(event)" onmouseUp="changeSizeEnd(event)" style="position:relative; left:200px; top:150px; width:400px; height:300px; cursor:move">
</body>
</html>