function OpenLinkHref(el, descFind, nomeAttrib, openT) { // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // script per link interni sviluppato da Ivo Sansovini // formato da usare: parte di descrizione del file da aprire // formato da usare: parte di descrizione del file da aprire // tutti i parametri: OpenLinkHref(this, 'descFind', 'nomeAttrib', 'openT') // descFind: '[nn]' o '[nn]descrizione (o parte) link da trovare (sost. descriz. del link)' opz. nn indica la posizione di inizio ricerca // ora descFind accetta il formato JS ExpReg (con o senza nn iniziale) /cerca/i (i=non considera maius/minusc) // nomeAttrib: '' o nome attributo che contiene desc. link es. 'Title' // openT: '' o '_blank' apre in nuova scheda o '_self' apre nella scheda corrente o // 'height=200,width=200,left=20,top=20' opzione ,resizable=yes default // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // alert(el.innerHTML + " " + descFind); var PosinDesc = -1; if (el === undefined) {alert("errore manca (this)"); return;} if (descFind === undefined) { descFind = el.innerHTML; } else { var risPosinDesc = parseInt(descFind.substring(0, 2), 10) // alert("risPosinDesc " + risPosinDesc + "sub desc " + descFind.substring(0,1)); if (!isNaN(risPosinDesc)) { PosinDesc = risPosinDesc; descFind = descFind.substring(2); } if ((descFind + "").length <= 1) {descFind = el.innerHTML} } if (nomeAttrib != undefined) { if (nomeAttrib > "") {descFind = el.getAttribute(nomeAttrib)} } if (openT === undefined) { openT = "_blank"; } else { if ((openT + "").length < 4) {openT = "_blank";} } if ((descFind + "").length <= 1) { alert("errore nella descrizione di ricerca del link"); return; } var wTabIndex = el.tabIndex // salvataggio tabIndex per Link chiamante (normalmente sono tutti a zero) el.tabIndex = -978 // numero negativo sicuramente non usato var LdF = descFind.length; var WdescF = descFind; if (descFind.substring(0,1) == "/") { if (descFind.substring(LdF - 2, LdF - 1) == "/") { descFind = new RegExp(descFind.substring(1, LdF - 2), descFind.substring(LdF - 1, LdF)); } else { if (descFind.substring(LdF - 1, LdF) == "/") { descFind = new RegExp(descFind.substring(1, LdF - 1)); } } } var All = document.getElementsByTagName("a"); for (var i = 0; i < All.length; i++) { var eltxt = All[i].innerHTML; var elhref = All[i].href; var risSearch; if ((eltxt.search(descFind) >= 0) && (All[i].tabIndex != el.tabIndex)) { if (eltxt.search(">") > 0) { eltxt = eltxt.substring(eltxt.search(">")+1); } if (PosinDesc == -1) { risSearch = (eltxt.search(descFind) >= 0); } else { risSearch = (eltxt.search(descFind) == PosinDesc); } if (risSearch) { el.tabIndex= wTabIndex // ripristino tabIndex (caso trovato) if (openT.length > 8) { window.open(elhref, "WinPopUp", openT); } else { window.open(elhref, openT); } return false; // impedisce lancio di href del link se inserito return prima della funzione // break; } // fine open poichè trovato esatto } // fine trovato simile } // fine loop el.tabIndex = wTabIndex // ripristino tabIndex (caso NON trovato) // alert("NON TROVATO LINK: <" + descFind + ">"); alert("NON TROVATO LINK: <" + WdescF + "> (L." + LdF + " Pos." + PosinDesc + ")"); }