Salve, ho un problema: il codice javascript riportato di sotto serve a mostrare e nascondere un DIV con un link che varia a seconda se il DIV e' mostrato o no. Il link e' il secondo e terzo valore della funzione che ho evidenziato in neretto. Ora volevo sapere, se al posto del testo evidenziato, volessi mettere un'immagine cosa devo scrivere?
if(document.getElementById && document.createElement){
document.write('<style type="text/css">*.toggle{display:none}</style>');
window.onload=function(){
/*le modifiche allo script vanno solo fatte qui*/
Attiva("commenti","mostra commenti","nascondi commenti");
Attiva("immagine","visualizza immagine","nascondi immagine");
}
}
function Attiva(id,s1,s2){
var el=document.getElementById(id);
el.style.display="none";
var c=document.createElement("div");
var link=document.createElement("a");
link.href="#";
link.appendChild(document.createTextNode(s1));
link.onclick=function(){
link.firstChild.nodeValue = (link.firstChild.nodeValue==s1) ? s2 : s1;
el.style.display=(el.style.display=="none") ? "block" : "none";
return(false);
}
c.appendChild(link);
el.parentNode.insertBefore(c,el);
}
if(document.getElementById && document.createElement){
document.write('<style type="text/css">*.toggle{display:none}</style>');
window.onload=function(){
/*le modifiche allo script vanno solo fatte qui*/
Attiva("commenti","mostra commenti","nascondi commenti");
Attiva("immagine","visualizza immagine","nascondi immagine");
}
}
function Attiva(id,s1,s2){
var el=document.getElementById(id);
el.style.display="none";
var c=document.createElement("div");
var link=document.createElement("a");
link.href="#";
link.appendChild(document.createTextNode(s1));
link.onclick=function(){
link.firstChild.nodeValue = (link.firstChild.nodeValue==s1) ? s2 : s1;
el.style.display=(el.style.display=="none") ? "block" : "none";
return(false);
}
c.appendChild(link);
el.parentNode.insertBefore(c,el);
}