用Js来PoSt提交表单查询Ip

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Ip查询 by 左岸右转</title>
<SCRIPT>
//Ip查询 by 左岸右转 2011.3.30 
var xmlhttp;
function loadXMLDoc(url) {
xmlhttp=null;
if (window.XMLHttpRequest) {
// code for all new browsers
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject) {
// code for IE5 and IE6
xmlhttp=new ActiveXObject("Microsoft. XMLHTTP") ;
}
if (xmlhttp!=null) {
strA = "ip="+document.form1.remark.value;
xmlhttp .onreadystatechange=state_Change ;
xmlhttp.open("post",url,false);
xmlhttp.setRequestHeader("Content-Length",strA.length);
xmlhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");//没有这句就玩不转拉
xmlhttp.send(strA);
}
else {
alert("Your browser does not support XMLHTTP.");
}
}
function state_Change() {
if (xmlhttp.readyState==4) {
// 4 ="loaded"
if (xmlhttp.status==200) {
// 200 = OK
// ...our code here...
    //   view.innerHTML =xmlhttp.responseText;
echo(xmlhttp.responseText);
} else {
alert("网络出错……");
}
}
else {
      //document.form1.remark.value
view.innerHTML ="<br>数据加载中……";

}
} 

</SCRIPT>

<style type="text/css">
<!--
body {
background-color: #000000;
color: #CCCCCC;
}
a:link, a:active, a:visited {
color: #0000FF;
text-decoration: none;
}
-->
</style>

</head> 
<body> 
<center>
<script type="text/javascript">
function echo(a){
b=a.indexOf("(c)")-7;
//a.substring
s=a.slice(a.indexOf("查询")+4,b);
s=s.replace(new RegExp("<","ig"),"<");
s=s.replace(new RegExp(">","ig"),">");
s=s.replace(new RegExp("\r\n","ig"),"<br>");

//document.form1.remark.value =a;
//document.form1.remark.rows=10;
view.innerHTML =a.slice(a.indexOf("查询")+4,b);;
}
xmlot=bloadXMLDoc;
//xmlot("http://wap.baidu.com";);
</script>
<table border="1" width="100%" cellspacing="0" cellpadding="5" bordercolor="#999999">
<form name="form1">
<tr bgcolor="#666666"><td onclick=';'>
Ip查询</td></tr>
<tr><td>
<textarea name="remark" rows="1" cols="24">202.192.121.189</textarea>
<br/>
</td></tr>
<tr bgcolor="#666666"><td>
<span  onclick='xmlot("http://wap.ip138.com/ip.asp";)
;'>查询</span>
</td></tr>
</form>
</table>
<div id=view align="left"></div>
</center>
</body>
</html>

发表评论