1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
| <HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
var first=-1
var x,y,x2,y2,topdiv,leftdiv,blx, bly
function GestionClick() {
first++;
if(first==0){
if(parseInt(navigator.appVersion) >=4){
if(navigator.appName == 'Netscape'){
x=window.event.x;
y=window.event.y;
}
else{
x = event.x ;
y = event.y;
}
}
// x=window.event.x;
// y=window.event.y;
topdiv=y;
leftdiv=x;
blx=x;
bly=y;
affiche();
first=1;
}
if(first==2){
var sendem=confirm('validez vous la capture ?\n\- Coordonnées du coin en haut à gauche: \('+leftdiv+','+topdiv+'\)\n\- Coordonnées du coin en bas à droite: \('+blx+','+bly+'\)');
first=-1,topdiv=0,leftdiv=0,blx=0,bly=0;
affiche();
//ici il ne te reste plus qu'a chopper le top left top+height left+width ....
}
}
function drawdiv(){
document.getElementById('dotframe').style.display='none'
if (first==1){
switch (true){
case (window.event.x || event.x)< parseInt(document.getElementById('ecran').offsetLeft):
x2=parseInt(document.getElementById('ecran').offsetLeft)
break;
case (window.event.x || event.x)>parseInt(document.getElementById('ecran').offsetLeft)+parseInt(document.getElementById('ecran').offsetWidth):
x2=parseInt(document.getElementById('ecran').offsetLeft)+parseInt(document.getElementById('ecran').offsetWidth)
break;
default:
x2=(window.event.x||event.x);
}
switch (true){
case (window.event.y||event.y)< parseInt(document.getElementById('ecran').offsetTop):
y2=parseInt(document.getElementById('ecran').offsetTop)
break;
case (window.event.y||event.y)>parseInt(document.getElementById('ecran').offsetTop)+parseInt(document.getElementById('ecran').offsetHeight):
y2=parseInt(document.getElementById('ecran').offsetTop)+parseInt(document.getElementById('ecran').offsetHeight)
break;
default:
y2=(window.event.y||event.y);
}
topdiv=(y2<y)?y2:y;
leftdiv=(x2<x)?x2:x;
x2=(x2<leftdiv)?x:x2;
y2=(y2<topdiv)?y:y2;
blx=(x2<x)?x:x2;
bly=(y2<y)?y:y2;
affiche();
document.getElementById('dotframe').style.top=topdiv+'px';
document.getElementById('dotframe').style.left=leftdiv+'px';
document.getElementById('dotframe').style.height=(bly-topdiv)+'px';
document.getElementById('dotframe').style.width=(blx-leftdiv)+'px';
document.getElementById('dotframe').style.display='block';
}
}
function affiche(){
document.test.x.value = leftdiv;
document.test.y.value = topdiv;
document.test.x2.value = blx;
document.test.y2.value = bly;
}
//--></SCRIPT>
</HEAD>
<BODY onclick="GestionClick()" onmousemove="drawdiv()">
<FORM NAME="test">
<table>
<tr>
<td>X:</td>
<td><INPUT TYPE="TEXT" NAME="x" SIZE="4"></td>
<td>Y:</td>
<td><INPUT TYPE="TEXT" NAME="y" SIZE="4"></td>
</tr>
<td>X2:</td>
<td><INPUT TYPE="TEXT" NAME="x2" SIZE="4"></td>
<td>Y2:</td>
<td><INPUT TYPE="TEXT" NAME="y2" SIZE="4"></td>
</tr>
</table>
</FORM>
<div id="ecran" style="position:absolute;top:100px; left:100px">
<img id="image" src="imagetest.gif" />
</div>
<div id="dotframe" style="position:absolute;display:none;height:0px;width:0px;background-color:none;border:1px gray;z-index:2;top:0px;left:0px;border-style:dotted;font-size:0px;"></div>
</BODY>
</HTML> |
Partager