Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1059 connectés 

  FORUM HardWare.fr
  Programmation
  HTML/CSS

  envoyer référence a monObjet.addEventListener() à la fonction invoquée

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

envoyer référence a monObjet.addEventListener() à la fonction invoquée

n°1730944
jokari34
Posté le 12-05-2008 à 19:00:18  profilanswer
 

Bonjour
 
Je veux associer un evenement a un element de formulaire HTML.
Au lieu du onlick dans la balise je souhaite utilsier la méthode addEventlistener
afin de separer HTML et code Javascript.
 
Or cette méthode ne permet pas de faire la meme chose que onclick="myFunction(this);"
mais uniquement  onclick="myFunction()'
 
Ma question est :
Comment a travers myObject.addEvenetListener('click', 'myFunction', false) , puis je envoyer la référence de myObject a myFunction() ?
Je pense qu'il est possible de le retrouver via l'objet evt qui est envoyé automatiquement par addEvenetListener a myfunction()
mais je sais pas comment...
 
merci

mood
Publicité
Posté le 12-05-2008 à 19:00:18  profilanswer
 

n°1730947
masklinn
í dag viðrar vel til loftárása
Posté le 12-05-2008 à 19:07:12  profilanswer
 

http://www.quirksmode.org/js/events_advanced.html


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1730952
jokari34
Posté le 12-05-2008 à 19:29:52  profilanswer
 


d'apres ceci :
 

Citation :

element.addEventListener('click',doSomething,false);
another_element.addEventListener('click',doSomething,false);
 
function doSomething() {
 this.style.backgroundColor = '#cc0000';
}


Je peux donc utiliser directement "this" dans doSomething(), qui est la référence implicite à another_element
puisque dans la pile des evenements, c'est le dernier objet a invoquer doSomething().
 
c'est bien ca ?
si oui j'ai donc ma réponse.

n°1730954
masklinn
í dag viðrar vel til loftárása
Posté le 12-05-2008 à 19:35:47  profilanswer
 

non, t'as pas tout lu, ça va pas marcher sous MSIE


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1730964
jokari34
Posté le 12-05-2008 à 20:08:10  profilanswer
 

doit bien y avoir des frameworks qui respectent les modèles W3C et Microsoft

n°1730982
masklinn
í dag viðrar vel til loftárása
Posté le 12-05-2008 à 20:51:23  profilanswer
 

wat?


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1732182
jokari34
Posté le 15-05-2008 à 13:12:08  profilanswer
 

ben en général les frameworks Javascript implémentent les 2 cas d'usage
d'objets, à la sauce W3c et sauce MS

n°1732203
masklinn
í dag viðrar vel til loftárása
Posté le 15-05-2008 à 14:26:36  profilanswer
 

non, ils implémentent une approche unifiée qui prend en charge les problèmes de plus bas niveau et évitent de s'emmerder avec ça, et avec nombre d'autres problèmes.


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1732237
jokaritaff
Posté le 15-05-2008 à 15:09:21  profilanswer
 

ok
merci


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  HTML/CSS

  envoyer référence a monObjet.addEventListener() à la fonction invoquée

 

Sujets relatifs
Appel périodique d'une fonction??gérer une fonction d'un programme automatiquement?
inclure fonction C dans du C++Extraire une seule valeur d'une fonction retournant un vecteur
La référence d'objet n'est pas définie à une instance d'un objet.Appel d'une fonction
DirectShow:La fonction GetCurrentBuffer ne recupére pas le buffer??Fonction de calcul de stock par ordre d'insertion
pbm avec trigger avec fonction pour replication sur oraclereference a un autre fichier c++
Plus de sujets relatifs à : envoyer référence a monObjet.addEventListener() à la fonction invoquée


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)