Puha, den var svær... her er lidt at arbejde videre på ...
lægger lige et svar samtidig, hvis det nu kan bruges :o)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"><title>Ingen titel</title>
<style type="text/css">
html,body{margin:0px;padding:0px;border:0px;}
body{margin:10px;}
#imgsel{margin:10px 0px;}
#apd{cursor:move;display:none;position:absolute;top:70px;left:10px;width:10px;height:10px;overflow:hidden;background:transparent;border:1px solid #fff;}
#dislo{position:absolute;top:0px;left:0px;width:0px;height:10px;background:transparent;}
#imgholder{position:relative;}
</style>
<script type="text/javascript">
var mp={"x":0,"y":0,"mpxa":0,"mpya":0,"mpxaa":0,"mpyaa":0}; // Mus positions object
var dp={"x":0,"y":0,"w":0,"h":0}; // Billede oplysnings object
var sc={"apd":1,"dislo":1,"dis":"","ditv":"","dith":"","dibv":"","dibh":"","dimx":"","dimy":"","dist":"","disl":"","disw":"","dish":""}; //Shortlink object
var chkfunc=0; // Funktions bestemmer
/* IE kontrol - af hensyn til musplacerings bug */
var IE=((document.all)&&(navigator.userAgent.indexOf("Opera")==-1))?true:false;
if(!IE)document.captureEvents(Event.mousemove)
window.onload=function(){
/* Short link aktivering */
for(i in sc)sc[i]=(sc[i]==1)?document.getElementById([i]):document.getElementsByName([i])[0];
/* Henter billedet position samt størrelse */
tn=sc.dis;
dp.x=tn.offsetLeft;
dp.y=tn.offsetTop;
dp.w=tn.offsetWidth;
dp.h=tn.offsetHeight;
while(tn=tn.offsetParent){
dp.x+=tn.offsetLeft;
dp.y+=tn.offsetTop;
}
/* Midlertidig output af dp objectets billede oplysninger */
sc.dist.value=dp.y;
sc.disl.value=dp.x;
sc.disw.value=dp.w;
sc.dish.value=dp.h;
/* Overfører width og height samt baggrund til ovenliggende div */
sc.dislo.style.width=dp.w+"px";
sc.dislo.style.height=dp.h+"px";
sc.dislo.style.background="url('"+sc.dis.src+"')";
confimg();
confdiv();
}
document.onmouseup=function(){chkfunc=0;}
document.onmousemove=function(e){
if(IE){
dmcst=(tmenu=document.documentElement.scrollTop)?tmenu:document.body.scrollTop;
dmcsl=(lmenu=document.documentElement.scrollLeft)?tmenu:document.body.scrollLeft;
dmcy=event.clientY+dmcst;
dmcx=event.clientX+dmcsl;
}else{
dmcy=e.pageY;
dmcx=e.pageX;
}
mp.x=dmcx;
mp.y=dmcy;
/* Midlertidig output af position ... - husk at
deaktivere i objectet sc også ved fjernelse */
sc.dimx.value=dmcx;
sc.dimy.value=dmcy;
}
function divpaint(){
sc.apd.style.width=((mp.x-dp.x)-sc.ditv.value.match(/[\d]*/g)[2])+"px";
sc.apd.style.height=((mp.y-dp.y)-sc.ditv.value.match(/[\d]*/)[0])+"px";
sc.dith.value=sc.ditv.value.match(/[\d]*/)[0]+","+(parseInt(sc.ditv.value.match(/[\d]*/g)[2])+parseInt(sc.apd.style.width.replace("px","")));
sc.dibv.value=parseInt(sc.ditv.value.match(/[\d]*/g)[0])+parseInt(sc.apd.style.height.replace("px",""))+","+sc.ditv.value.match(/[\d]*/g)[2];
sc.dibh.value=sc.dith.value.match(/[\d]*/g)[2]+","+sc.dibv.value.match(/[\d]*/)[0];
}
function confimg(){
tn=sc.dislo;
tn.onmousedown=function(){
chkfunc=1;
sc.apd.style.width="0px";
sc.apd.style.height="0px";
sc.apd.style.top=mp.y+"px";
sc.apd.style.left=mp.x+"px";
sc.apd.style.display="block";
sc.ditv.value=(mp.y-dp.y)+","+(mp.x-dp.x);
}
tn.onmousemove=function(){if(chkfunc==1)divpaint();}
}
function confdiv(){
tn=sc.apd;
tn.onmousedown=function(){
chkfunc=2;
mp.mpya=mp.y;
mp.mpxa=mp.x;
mp.mpxaa=sc.apd.style.left.replace("px","");
mp.mpyaa=sc.apd.style.top.replace("px","");
}
tn.onmousemove=function(){if(chkfunc==1)divpaint();if(chkfunc==2)divmove();}
}
function divmove(){
sc.apd.style.left=mp.mpxaa-mp.mpxa+mp.x+"px";
sc.apd.style.top=mp.mpyaa-mp.mpya+mp.y+"px";
}
</script>
</head><body>
<br><br><br>
<div id="imgholder"><img name="dis" src="b.jpg" id="disid"><div id="dislo"></div></div>
<form id="imgsel" action="#" method="post"><div>
<b style="text-decoration:underline">IMG - <DIV> OPLYSNINGER:</b><br>
Top venstre hjørne: <input type="text" name="ditv"><br>
Top højre hjørne: <input type="text" name="dith"><br>
Nederste venstre hjørne: <input type="text" name="dibv"><br>
Nederste højre hjørne: <input type="text" name="dibh"><br><br>
<b style="text-decoration:underline">Midlertidige mouse position oplysninger:</b><br>
X-position: <input type="text" name="dimx"><br>
Y-position: <input type="text" name="dimy"><br><br>
<b style="text-decoration:underline">Midlertidige billede oplysninger:</b><br>
Afstand til absolut left: <input type="text" name="disl"><br>
Afstand til absolut top: <input type="text" name="dist"><br>
Bredde på img: <input type="text" name="disw"><br>
Højde på img: <input type="text" name="dish">
</div></form>
<div id="apd"></div>
</body></html>