Re bonjour,

Je post un second sujet car j'ai un autre problème avec ce script :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<html>
 
<head>
	<title>Bloc</title>
<style type="text/css">
.limite{
	position:absolute; top:100px; left:100px; z-index:400;
	width:740px; height:70%; background-color:#B3B3B3; visibility:visible;
}
.bloc1{
	position:absolute; top:50px; left:50px; z-index:500;
	width:100px; height:20px; background-color:red; visibility:visible;
}
.bloc2{
	position:absolute; left:50px; top:50px; z-index:490;
	width:100px; height:20px; background-color:blue; visibility:visible;
}
.bloc3{
	position:absolute; left:50px; top:50px; z-index:480;
	width:100px; height:20px; background-color:yellow; visibility:visible;
}
.bloc4{
	position:absolute; left:50px; top:50px; z-index:470;
	width:100px; height:20px; background-color:green; visibility:visible;
}
</style>
 
<script language="JavaScript" type="text/JavaScript">
// Fonction position souris.
function pos_souris(e){
	// Position X,Y.
	x_pos_souris = (navigator.appName.substring(0,3) == "Net")? e.pageX:event.x+document.body.scrollLeft;
	y_pos_souris = (navigator.appName.substring(0,3) == "Net")? e.pageY:event.y+document.body.scrollTop;
}
 
// Fonction déplacement.
function deplacement(){
	var y_pos_bloc = document.getElementById("bloc1").style.top;
	var x_pos_bloc = document.getElementById("bloc1").style.left;
	document.getElementById("bloc1").style.top = y_pos_souris-y_pos_bloc;
	document.getElementById("bloc1").style.left = x_pos_souris-x_pos_bloc;
	window.setTimeout("deplacement()",100);
}
 
// Non IE - Souris.
if(navigator.appName.substring(0,3) == "Net")document.captureEvents(Event.MOUSEMOVE);
// Lancement.
document.onmousemove = pos_souris;
</script>
 
</head>
 
<body>
 
<div id="bloc1" class="bloc1" onMouseDown="deplacement();">Bloc1</div>
<div id="bloc2" class="bloc2">Bloc2</div>
<div id="bloc3" class="bloc3">Bloc3</div>
<div id="bloc4" class="bloc4">Bloc4</div>
 
</body>
 
</html>
Il plente au niveau de :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
var y_pos_bloc = document.getElementById("bloc1").style.top;
var x_pos_bloc = document.getElementById("bloc1").style.left;
Je ne comprend pas, pourtant les valeurs demandées sont bien éxistantes !

Merci de votre aide !