Erreut this

vinise Messages postés 33 Date d'inscription mardi 14 novembre 2006 Statut Membre Dernière intervention 2 décembre 2009 - 14 mai 2008 à 04:35
vinise Messages postés 33 Date d'inscription mardi 14 novembre 2006 Statut Membre Dernière intervention 2 décembre 2009 - 17 mai 2008 à 05:43
Bonjour a tous jai un petiti probleme avec prototype:

background : function()
    {
        this.BG = document.createElement('div');
        this.BG.className = 'BG';
        Event.observe(this.BG,'click',this.close);
        document.body.appendChild(this.BG)
    },
open : function()
    {
        this.background();
    },
close :function()
    {
        document.body.removeChild(this.BG);
    },

japelle ma fonction open mais maleureusement quand je clique sur la div elle ne disparait pas jai limpression quil ne reconnait pas le this dans la fonction close...

qqun a une solution?

merci
vince

2 réponses

PetoleTeam Messages postés 3426 Date d'inscription lundi 26 décembre 2005 Statut Membre Dernière intervention 14 janvier 2011 17
16 mai 2008 à 00:03
Bonjour,
<table bgcolor="#e6effe" border="0" cellpadding="5" cellspacing="0" width="100%">----, qqun a une
solution?</td>
</td></tr></tbody></table>
background : function()
  {

    this.BG = document.createElement('div');
    this.BG.className =
'BG';
    this.BG.id = 'D_TEST'; // mettre un id sur
le DIV
    //
Event.observe(this.BG,'click',this.close);

    document.body.appendChild(this.BG)
    this.BG.onclick =
function(){document.body.removeChild( document.getElementById('D_TEST'))};

  },

cela ne répond pas complétement à la question mais devrait marcher...

;O)
0
vinise Messages postés 33 Date d'inscription mardi 14 novembre 2006 Statut Membre Dernière intervention 2 décembre 2009
17 mai 2008 à 05:43
Merci jai trouver un autre moyen sinon qui est aussi simple

this.BG = document.createElement('div');
    this.BG.className = 'BG';

    ceci=this;
    document.body.appendChild(ceci.BG)

et sa fonctionne aussi

Merci quand meme
0
Rejoignez-nous