Ho un altro quesito molto interessante da proporre e che non riesco a risolvere nonostante varie ricerche sulla rete.
Allora. Il codice seguente permette di ricavare il testo selezionato in una pagina (compatibile con i vari browser):
La cosa funziona molto bene.codice:function getSel() { var txt = ''; var foundIn = ''; if (window.getSelection) { txt = window.getSelection(); foundIn = 'window.getSelection()'; } else if (document.getSelection) { txt = document.getSelection(); foundIn = 'document.getSelection()'; } else if (document.selection) { txt = document.selection.createRange().text; foundIn = 'document.selection.createRange()'; } else return; document.forms[0].selectedtext.value = 'Found in: ' + foundIn + '\n' + txt; }
QUello che serve a me, pero', e' conoscere l'identita' del padre del testo selezionato. Ovvero sapere quale e' il primo tag che contiene il testo (anche un semplice B).
E' possibile tutto questo?
Grazie e alla prossima.

Rispondi quotando