window.onload = function() {
  var xhr = createXMLHttpRequest();
  xhr.onreadystatechange = function() {
    if (xhr.readyState==4) { // Request is finished
      if (xhr.status==200) {
        $("sandbox").innerHTML = "Retrieved from server ...<hr/>";
        $("sandbox").innerHTML += xhr.responseText;
      } else {
        alert("Message returned, but with error status.");
      }
    }
  }
  xhr.open("GET", "message.html", true);
  xhr.send(null);
}

function createXMLHttpRequest() {
  try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
  try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
  try { return new XMLHttpRequest(); } catch(e) {}
  alert("XMLHttpRequest not supported");
  return null;
}

function $(id) { return document.getElementById(id); }
