1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
function unpopall()
{
var myAs = document.getElementsByTagName('a');
for (var a = 0; a < myAs.length; ++a) {
// Si le lien a une classe de type pop
if (myAs[a].className == 'pop') {
// on extrait l'id de la popup à partir du href
var pop = document.getElementById(myAs[a].href.substring(myAs[a].href.lastIndexOf('#') + 1));
// si la popup existe on l'affiche (display block)
if (pop) {
pop.style.display = 'none';
}
}
}
}
function pop()
{ var myAs = document.getElementsByTagName('a');
for (var a = 0; a < myAs.length; ++a) {
// Si le lien a une classe de type pop
if (myAs[a].className == 'pop') {
// on extrait l'id de la popup à partir du href
var pop = document.getElementById(myAs[a].href.substring(myAs[a].href.lastIndexOf('#') + 1));
// si la popup existe on l'affiche (display block)
if (pop) {
pop.style.display = 'none';
myAs[a].onclick = function() {
thisPopup = document.getElementById(this.href.substring(this.href.lastIndexOf('#') + 1))
unpopall();
thisPopup.style.display = (thisPopup.style.display == 'none') ? 'block' : 'none';
return false;
};
// on efface la popup en cliquant sur le bouton ou la fenêtre
pop.onclick = function()
{
this.style.display = 'none';
};
}
}
}
} |