codice:
function Search(sText) {
if (sText == "") {
return(false);
}
if (document.all) { // Internet Explorer
var bFound;
var oTextRange = window.document.body.createTextRange();
for (var iPos = 0; (iPos <= iNum &&
(bFound = oTextRange.findText(sText))); iPos++) {
oTextRange.moveStart("character", 1);
oTextRange.moveEnd("textedit");
}
if (bFound) {
oTextRange.moveStart("character", -1);
oTextRange.findText(sText);
oTextRange.select();
oTextRange.scrollIntoView();
iNum++;
} else {
if (iNum > 0) {
alert("Parola '"+sText+"' trovata "+iNum+" volte nella pagina.")
iNum = 0;
//Search(sText);
} else {
window.alert("Testo non trovato.");
}
}
}
}
Ragazzi, con questo codice funziona tutto.Come posso ricercare invece che in tutta la pag solo nel div????
Provando a sostituire
window.document.body.createTextRange();
con
document.getElementById('centro').createTextRange( );
Non vā.