Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/04/2009, 09:49
worldPeace_Plis
Usuario no validado
 
Fecha de Ingreso: marzo-2007
Mensajes: 238
Antigüedad: 18 años
Puntos: 5
conocer nombre de obj que invoca funcion

hola amigos, como puedo saber el nombre del objeto que ha llamado a una funcion, p.e. tengo 4 id's diferentes que llaman a una misma, entonces como hago para saber quien llamo, en actionscript uso algo como this._name

Código:
<table align="center" width="540" border="0" class='tablenews'>
<!-- PRINCIPALES -->
  <tr>
    <td colspan="2">
	<div id="newscontent">Lo Principal<br /><img src="./preload_3.gif" /></div>
	</td>
  </tr>
  <tr>
    <td colspan="2">
<!-- TEMAS -->
<div id="newsthemes" style="background:#FFFFCC; display:block">
<a href="#">tema 1</a><a href="#">tema 2</a><a href="#">tema 3</a>
</div>
<!-- fin:TEMAS -->
	</td>
  </tr>
<!-- fin:PRINCIPALES -->
<!-- ITEMS -->
<tr>
<td id="item1" style="padding: .2em; width: 270px; height: 60px; border: thin solid
silver; background:#FFFFFF"
onMouseover = "this.style.borderColor = '#efefef',this.style.backgroundColor='#EFEFEF'"
onMouseout = "this.style.borderColor = 'silver',this.style.backgroundColor='#FFFFFF'">&nbsp;1
</td>
<td id="item2" style="padding: .2em; width: 270px; height: 60px; border: thin solid
silver; background:#FFFFFF"
onMouseover = "this.style.borderColor = '#efefef',this.style.backgroundColor='#EFEFEF'"
onMouseout = "this.style.borderColor = 'silver',this.style.backgroundColor='#FFFFFF'">&nbsp;2
</td>
  </tr>
  <tr>
<td id="item3" style="padding: .2em; width: 270px; height: 60px; border: thin solid
silver; background:#FFFFFF"
onMouseover = "this.style.borderColor = '#efefef',this.style.backgroundColor='#EFEFEF'"
onMouseout = "this.style.borderColor = 'silver',this.style.backgroundColor='#FFFFFF'">&nbsp;3
</td>
<td id="item4" style="padding: .2em; width: 270px; height: 60px; border: thin solid
silver; background:#FFFFFF"
onMouseover = "this.style.borderColor = '#efefef',this.style.backgroundColor='#EFEFEF'"
onMouseout = "this.style.borderColor = 'silver',this.style.backgroundColor='#FFFFFF'">&nbsp;4
</tr>
<!-- fin:ITEMS -->
</table>
aqui mi duda onclick = newinfo llamaria esta funcion, pero no se quien fue de las 4 opciones...

Código javascript:
Ver original
  1. var maxchars = 100;
  2. var frases = new Array();
  3. frases[0] = 'hola gatito. Este tema habla de este item, mas contenido lorem ipsum san dsfer fdc bdfgdvcxc';
  4. frases[1] = 'hola perrito. Este tema habla de este item, mas contenido lorem ipsum san dsfer fdc bdfgdvcxc';
  5. frases[2] = 'hola pajarito. Este tema habla de este item, mas contenido lorem ipsum san dsfer fdc bdfgdvcxc';
  6. frases[3] = 'hola mundito. Este tema habla de este item, mas contenido lorem ipsum san dsfer fdc bdfgdvcxc';
  7.  
  8. function newsinfo()
  9. {
  10. alert ('desplegar informacion en '+maxchars)
  11. }
  12.  
  13. for (i=1; i<5; i++)
  14. {
  15. contenido = frases[i-1];
  16. itemcont = (contenido.length>maxchars) ? contenido.substring(0,maxchars) : contenido;
  17. itemcont += '<br /><div style="text-align:right"><a href="#">leer m&aacute;s &gt;&gt;</a></div>'
  18. document.getElementById('item'+i).innerHTML = 'DATE , item'+i+ ': ' + itemcont;
  19. document.getElementById('item'+i).onclick = newsinfo;
  20. }