案例:XML案例     状态:不可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript">
4
5
xmlHttp=null;
6
7
function showHint(str)
8
{
9
if (str.length==0)
10
  { 
11
  document.getElementById("txtHint").innerHTML="";
12
  return;
13
  }
14
try
15
  {// Firefox, Opera 8.0+, Safari, IE7
16
  xmlHttp=new XMLHttpRequest();
17
  }
18
catch(e)
19
  {// Old IE
20
  try
21
    {
22
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
23
    }
24
  catch(e)
25
    {
26
    alert ("Your browser does not support XMLHTTP!");
27
    return;  
28
    }
29
  }
30
url="/example/aspnet/gethint.aspx?q=" + str;
31
url=url+"&sid="+Math.random();
32
xmlHttp.open("GET",url,false);
33
xmlHttp.send(null);
34
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
35
}
36
</script> 
37
</head>
38
<body><form> 
39
First Name:
40
<input type="text" id="txt1"
41
onkeyup="showHint(this.value)">
42
</form><p>Suggestions: <span id="txtHint"></span></p> </body>
43
</html>