Bonjour,
Je suis en train de devenirà cause d'une fonction js.
J'initialise la variable width avec
et quand je "log" la valeur se trouvant dans width et en direct avec l'alerte du fond, j'obtiens 2 valeurs différentes.
Code : Sélectionner tout - Visualiser dans une fenêtre à part width = myPicture.offsetWidth;
Sérieusement, là je sèche. Je ne comprends pas mon erreure.
Si quelqu'un avait un petit instant pour regarder, ça serait sympa.
Merci d'avance.
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 function ChargeImage(NumImage) { width = 0; height = 0; var myPicture = document.images[2]; myPicture.src = "./images/img" + (NumImage) +".jpg"; width = myPicture.offsetWidth; height = myPicture.offsetHeight; var posX = (parseInt(leftMargin) - (parseInt(width) / 2 )); var posY = (parseInt(topMargin) - (parseInt(height) / 2 )); maDiv = document.getElementById('picture'); // Warning!! Position "Y X" maDiv.style.padding = ""+posY+"px "+posX+"px"; maDiv.onclick = function(){alert('click ! image en cours: '+myPicture.src+'->'+width+'X'+height+'VS'+myPicture.offsetWidth+'X'+myPicture.offsetHeight);}; }
Partager