Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing value not a reference
Message
De
21/03/2016 05:50:38
 
 
À
20/03/2016 21:21:20
Information générale
Forum:
Javascript
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01633405
Message ID:
01633412
Vues:
44
>In this line:
>
>
>   oDiv.onmouseout=function(e) {OnMouseOut(e,tcAlignID,lnLeft,lnTop,lnWidth,lnHeight)}
>   lnLeft=lnLeft-tnAlignOffsetLeft
>   lnTop=lnTop-tnAlignOffsetTop
>
>
>The values of lnLeft and lnTop, for example, are passed by reference.
>
>However, once the event is triggered, the value is not what was passed but the adjusted value in the lines following.
>
>What would be the best approach to pass a variable value?

Integers are passed by value (I'm assuming lnLeft/lnTop *are* integers) so something else must be going on.
e.g:
                 var i = 5;
                  oDiv.onmouseout = function(e) {
                      OnMouseOut(e, i);
                      alert("After"+i); // 5
                  };
                  
 
                  function OnMouseOut(e, i) {
                      i = i + 1;
                  }
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform