简短的AJAX达成(HELLO AJAX)

复制代码 代码如下:

客户端部分:

用js获取本地Computer音讯(然而只好在IE浏览器下才行,别的浏览器其获得不到的):

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“;
<html xmlns=”;
<head>
<title>无标题页</title>
<script type=”text/javascript”>
function getClientPcName()
{
var WshShellPcName = new ActiveXObject(“WScript.Network”);
var ComputerName = WshShellPcName.ComputerName ;
return ComputerName;
}

复制代码 代码如下:

复制代码 代码如下:

function getClientIp()
{
var WshShellIp = new ActiveXObject(“rcbdyctl.Setting”);
var ip = WshShellIp.GetIPAddress;
return ip;
}
alert(getClientPcName()+” “+getClientIp());
</script>
</head>
<body>
</body>

<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html”/>
<script language=”javascript”>
var ajax;
function createAjax()
{
if(window.ActiveXObject)
{
try
{
return new ActiveXObject(“Msxm12.XMLHTTP”);
}
catch(e)
{
try
{
return new
ActiveXObject(“Microsoft.XMLHTTP”);
}
catch(e2)
{
return null;
}
}
}
else if(window.XMLHttpRequest)
{
return new XMLHttpRequest();
}
else
{
return null;
}
}
function onRcvData()
{
if(ajax.readyState==4)
{
if(ajax.status==200)
{
var content=document.getElementById(‘content’);
content.innerHTML=ajax.responseText;
}
else
{
alert(“error”);
}
}
}
function ajaxSendRequest(uri)
{
ajax=createAjax();
if(!ajax)
{
alert(“no”);
return 0;
}
ajax.onreadystatechange=onRcvData;
ajax.open(“GET”,uri,true);
ajax.send(“”);
}
</script>
<title>Hello AJAX</title>
</head>
<body>
<div id=”content”></div>
<br>
<input type=”button” value=”Hello”
onclick=”ajaxSendRequest(‘;
</body>
</html>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“;
<html xmlns=”;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″
/>
<title>ieTest</title>
<script type=”text/javascript”>
window.onload = getusername;
function getusername(){
//js获取计算机新闻
var WshNetwork = new ActiveXObject(“WScript.Network”);
var WshShell = new ActiveXObject (“WScript.Shell”);
var $lDomain = document.getElementById(‘lDomain’),
$lcName = document.getElementById(‘lcName’),
$luName = document.getElementById(‘luName’),
$lDomainDn = document.getElementById(‘lDomainDn’);
$lDomain.value =WshNetwork.UserDomain;
$lcName.value =WshNetwork.ComputerName;
$luName.value =WshNetwork.UserName;
$lDomainDn.value =WshShell.RegRead (“HKCU\\Volatile
Environment\\USERDNSDOMAIN”);
WshNetwork = null;
WshShell = null;
};

</html>

服务器端部分(hello.jsp)

</script>
</head>

在vs中还是能用,发布到IIS下面就老大了,请大师提示。

复制代码 代码如下:

<body>
<input type=’text’ id=’lDomain’ value=” />
<input type=’text’ id=’lcName’ value=” />
<input type=’text’ id=’luName’ value=” />
<input type=’text’ id=’lDomainDn’ value=” />
</body>
</html>

您可能感兴趣的篇章:

  • flex通过js获取ip和pcname示例代码
  • Flex通过JS获取客户端IP和测算机名的实例代码

<html>
<head>
<title>hellp</title>
</head>
<body>
<%
out.println(“HELLO AJAX”);
%>
</body>
</html>

复制代码 代码如下: !DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0…

复制代码 代码如下: html head meta
http-equiv=”Content-Type” content=”text/html”/ script
language=”javascript” var ajax; function createAjax() {
if(window….

发表评论

电子邮件地址不会被公开。 必填项已用*标注