Código:
  
Me dice que undefined si lo pongo directamente el document.write en la función con "texto" me lo hace bien no funciona el return y no tengo ni idea de pq.function createRequestObject(){
      var peticion;
      var browser = navigator.appName;
            if(browser == "Microsoft Internet Explorer"){
                  peticion = new ActiveXObject("Microsoft.XMLHTTP");
            }else{
                  peticion = new XMLHttpRequest();
}
return peticion;
}
var http = new Array();
function ObtDatos(url){
      var act = new Date();
      http[act] = createRequestObject();
      http[act].open('get', url);
      http[act].onreadystatechange = function() {
      if (http[act].readyState == 4) {
            if (http[act].status == 200 || http[act].status == 304) {
		  		var texto; 
				texto = http[act].responseText;
				 return texto;
			}
		}
	}
	http[act].send(null);
}
document.write(ObtDatos("http://midireccion/datos.php"));
Un slaudo y gracias.
 
