codice:
function assegnaXMLHttpRequest() {//compatibilità vari browser
var
XHR = null,
browserUtente = navigator.userAgent.toUpperCase();
if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
XHR = new XMLHttpRequest();
else if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0) {
if(browserUtente.indexOf("MSIE 5") < 0)
XHR = new ActiveXObject("Msxml2.XMLHTTP");
else
XHR = new ActiveXObject("Microsoft.XMLHTTP");
}
return XHR;
}
function getVal(param){//Richiesta ajax sincrona
var strURL=param;
var req = assegnaXMLHttpRequest();
req.open("GET", strURL, false);
req.send(null);
return req.responseText;
}
var sorgentePagina=getVal('/tuaCartella/tuaPagina.tuaEstensione');
if(sorgentePagina.indexOf('foglia')!=-1){
alert('Ho trovato la parola foglia');
}