MediaWiki:Gadget-AncreTitres.js
Une page de Wikipédia, l'encyclopédie libre.
Note : après avoir enregistré vos préférences, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Maj-Cmd-R sur Apple Mac) ;
Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5./** * AncreTitres * * Cette fonction fournit un lien vers une section de page en cliquant * sur le lien [ancre] à droite du titre de section. * * Auteurs : Pabix, Phe, Bayo -- Correctif apporté par Chphe * Date de dernière révision : 26 septembre 2009 * {{Projet:JavaScript/Script|AncreTitres}} */ var AncreTitres={ nom_ancre : "[URL]", nom_lien_interne : "[[lien]]", description : "Obtenir une URL vers cette section", descinterne : "Obtenir un [[Lien#interne]]", linkcolor : "", fontSize : "xx-small", fontWeight : "normal", afficheE : true, afficheI : true, } function ancrer(){ if (!document.getElementById('content')) return; var titres = document.getElementsByTagName("span"); var i = 0; var titre_courant; if (!AncreTitres.afficheI && !AncreTitres.afficheE) return; var prefixedServer = wgServer; if (wgServer.substr(0, 2) == "//") { if (document.URL.substr(0, 5) == "http:") prefixedServer = "http:" + wgServer; else if (document.URL.substr(0, 6) == "https:") prefixedServer = "https:" + wgServer; } for (i = 0 ; i < titres.length ; i++){ var titre_courant = titres[i].parentNode; if (!(titres[i].className.match(/mw-headline/gi))) continue; var ancre_nom = titres[i].id; var small; var link; span = document.createElement('span'); with(span ) { if (AncreTitres.linkcolor != "") style.color=AncreTitres.linkcolor; style.fontSize=AncreTitres.fontSize; style.fontWeight=AncreTitres.fontWeight; className = 'noprint ancretitres'; } if (AncreTitres.afficheE) { link = document.createElement('a'); with(link) { innerHTML=AncreTitres.nom_ancre; title=AncreTitres.description; setAttribute("ancre", prefixedServer + wgScript + "?title=" + wgPageName + "#" + ancre_nom ); setAttribute("onclick", "window.prompt(" + "'Lien : ', this.getAttribute('ancre'));" ); setAttribute("href", "javascript:;"); } span.appendChild(document.createTextNode(' ')); span.appendChild(link); } if (AncreTitres.afficheI) { link = document.createElement('a'); with(link) { innerHTML=AncreTitres.nom_lien_interne; title=AncreTitres.descinterne; setAttribute("ancre", "[[" + wgPageName + "#" + ancre_nom + "]]"); setAttribute("onclick", "window.prompt(" + "'Lien : ', this.getAttribute('ancre'));" ); setAttribute("href", "javascript:;"); } span.appendChild(document.createTextNode(' ')); span.appendChild(link); } titre_courant.appendChild(span); } } addOnloadHook(ancrer);