Script Zoom image IE firefox

Résolu
tropik99 Messages postés 2 Date d'inscription mercredi 28 juillet 2004 Statut Membre Dernière intervention 20 septembre 2005 - 20 sept. 2005 à 10:34
tropik99 Messages postés 2 Date d'inscription mercredi 28 juillet 2004 Statut Membre Dernière intervention 20 septembre 2005 - 20 sept. 2005 à 11:59
Bonjour,
J'ai trouvé sur le net un javascript qui permet de zoomez et dézoomer sur une image, je l'ai adapté pour le faire fonctionner avec un fichier FLASH, il fonctionne parfaitement sous IE et pas sous firefox ?
ERREUR: Erreur : whatcache.style has no properties
Fichier Source : [file:///C:/Documents%20and%20Settings/Administrateur/Bureau/test.htm file:///C:/Documents%20and%20Settings/Administrateur/Bureau/test.htm]
Ligne : 19
le code:
<html>
<HEAD>
<title>Cut&amp;Paste Image zoom in/out</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
var zoomfactor=0.05
function zoomhelper(){
if (parseInt(whatcache.style.width)>10&&parseInt(whatcache.style.height)>10){
whatcache.style.width=parseInt(whatcache.style.width)+parseInt(whatcache.style.width)*zoomfactor*prefix
whatcache.style.height=parseInt(whatcache.style.height)+parseInt(whatcache.style.height)*zoomfactor*prefix
}
}
function zoom(originalW, originalH, what, state){
if (!document.all&&!document.getElementById)
return
whatcache=eval("document."+what)
prefix=(state=="in")? 1 : -1
if (whatcache.style.width==("")||state=="restore"){ -------------- ligne19
whatcache.style.width=originalW
whatcache.style.height=originalH
if (state=="restore")
return
}
else{
zoomhelper()
}
beginzoom=setInterval("zoomhelper()",100)
}


function clearzoom(){
if (window.beginzoom)
clearInterval(beginzoom)
}
//-->
</script>
</HEAD>



[# Zoom In] |
[# Normal] |
[# Zoom Out]

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" name="myimage" width="511" height="816">



</object>

</html>


merci de votre aide.

2 réponses

cs_bultez Messages postés 13615 Date d'inscription jeudi 13 février 2003 Statut Membre Dernière intervention 15 octobre 2013 30
20 sept. 2005 à 11:39
bonjour,
déjà :

function zoom(originalW, originalH, what, state){
//if (!document.all&&!document.getElementById)
//return
//whatcache=eval("document."+what)
whatcache=document.getElementById(what);
...
en ajoutant id="myimage" au

il y a 2 name="myimage", ce qui
pourrait poser problème.
et il faut voir le reste.... @+
3
tropik99 Messages postés 2 Date d'inscription mercredi 28 juillet 2004 Statut Membre Dernière intervention 20 septembre 2005
20 sept. 2005 à 11:59
ok !
donc après vos corrections de code, cela fonctionne !
voiçi le code comple qui fonctionne sous : IE et Firefox.
<html>
<HEAD>
<title>Cut&amp;Paste Image zoom in/out</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
var zoomfactor=0.05
function zoomhelper(){
if (parseInt(whatcache.style.width)>10&&parseInt(whatcache.style.height)>10){
whatcache.style.width=parseInt(whatcache.style.width)+parseInt(whatcache.style.width)*zoomfactor*prefix
whatcache.style.height=parseInt(whatcache.style.height)+parseInt(whatcache.style.height)*zoomfactor*prefix
}
}
function zoom(originalW, originalH, what, state){
if (!document.all&&!document.getElementById)
return
whatcache=document.getElementById(what)
prefix=(state=="in")? 1 : -1
if (whatcache.style.width==""||state=="restore"){
whatcache.style.width=originalW
whatcache.style.height=originalH
if (state=="restore")
return
}
else{
zoomhelper()
}
beginzoom=setInterval("zoomhelper()",100)
}


function clearzoom(){
if (window.beginzoom)
clearInterval(beginzoom)
}
//-->
</script>
</HEAD>



[# Zoom In] |
[# Normal] |
[# Zoom Out]

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" name="myimage" width="511" height="816">



</object>

</html>
MERCI BEAUCOUP POUR VOTRE AIDE...
0
Rejoignez-nous