Bonjour,
je suis en train d'essayer de faire un script de "zoom/aperçu" d'image, le principe est simple voir une image dans ca vrai grandeur tout en limitant la div,
(même principe que cdiscount) .
Mon premier problème est d'afficher un petit cadre :
voila ou j'en suis :
http://mimagyc.ovh.org/zoom/
pour ce qui est du cadre, ca fonctionne sous IE mais pas sous FF, et le onmouseout ne fonctionne sous aucun des deux navigateur ...
Merci.
edit:
ca fonctionne comme ceci mais l'image qui suit le curseur sacade ...
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
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 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>image zoom</title> <style type="text/css"> <!-- body,td,th { font-family: Tahoma; font-size: 12px; color: #000000; } body { background-color: #CCCCCC; margin-left: auto; margin-top: auto; margin-right: auto; margin-bottom: auto; width:300px; height:500px; } .apercu { max-width:300px; max-height:300px; cursor:pointer; overflow:hidden; } .cadre { width:80px; height:40px; position:absolute; cursor:pointer; } --> </style> <script language="javascript" type="text/javascript"> function $(element) { var cont = document.getElementById(element); return cont; } function detectMouse(e){ if(parseInt(navigator.appVersion) >=4){ if(navigator.appName == 'Netscape'){ $('cadre').style.display = 'block'; $('cadre').style.left = e.clientX ; $('cadre').style.top = e.clientY; alert('marche'); } else{ $('cadre').style.display = 'block'; $('cadre').style.left = (event.x - 40) + 'px' ; $('cadre').style.top = (event.y - 20) + 'px' ; } } } function zoom(imgid) { if (imgid == "out") { $('cadre').style.display = "none"; } else { var img = $(imgid).innerHTML ; detectMouse(event); } } </script> </head> <body> <div id="temp1" onmouseover="zoom('temp1')" onmouseout="zoom('out')"> <img src="ro.jpg" class="apercu" /> <img id="cadre" class="cadre" src="cadre.png" style="left:0px;top:0px;display:none;" /> </div> </body > </html>
Partager