案例:XML案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript">
4
var xmlhttp;
5
function loadXMLDoc(url)
6
{
7
xmlhttp=null;
8
if (window.XMLHttpRequest)
9
  {// all modern browsers
10
  xmlhttp=new XMLHttpRequest();
11
  }
12
else if (window.ActiveXObject)
13
  {// for IE5, IE6
14
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
15
  }
16
if (xmlhttp!=null)
17
  {
18
  xmlhttp.onreadystatechange=state_Change;
19
  xmlhttp.open("GET",url,true);
20
  xmlhttp.send(null);
21
  }
22
else
23
  {
24
  alert("Your browser does not support XMLHTTP.");
25
  }
26
}
27
28
function state_Change()
29
{
30
if (xmlhttp.readyState==4)
31
  {// 4 = "loaded"
32
  if (xmlhttp.status==200)
33
    {// 200 = "OK"
34
    document.getElementById('p1').innerHTML="This file was last modified on: " + xmlhttp.getResponseHeader('Last-Modified');
35
    }
36
  else
37
    {
38
    alert("Problem retrieving data:" + xmlhttp.statusText);
39
    }
40
  }
41
}
42
</script>
43
</head>
44
<body>
45
46
<p id="p1">
47
The getResponseHeader() function returns a header from a resource.
48
Headers contain file information like length,