解决方案 »
- 层失去焦点后关闭
- javascript 函数调用问题
- button的onclick事件函数带参数
- 求http://bt1.btchina.net站点中鼠标放到电影名称上出来title效果的代码!!
- 游览器F11是全屏游览效果,有什么办法让用户不按F11用js实现这个效果吗?
- javascript里面的+号我控制不好
- ★★★★★★ 。。 高分求解难倒无数高手的问题 。。 ★★★★★★
- 帮帮啊,各位高手
- 有没有办法在一个FRAME里,只有TABLE带滚动条,别的控件不带滚动条?
- jq事件委托解绑问题
- xml 在Chrome如何读出数据,代码那里出问题了
- ie下image对象得到高度宽度不准确,ff下正常
希望下面的方法可以帮到你:http://www.scriptlover.com/pages/notes.asp?texts=%BF%E7%D3%F2
<title>CSDN积分查询--清洁工2008版</title>
<head>
<hta:application id="sofa" icon="sofa.ico" />
</head>
<body>
<div>
用户名:<input type="text" id="TextUsername" />
密码:<input type="password" id="TextPassword" />
目标用户:<input type="text" id="TextDestuser" />
<input type="button" value="开始查询" onclick="ButtonStartClick();" id="ButtonStart" />
</div>
<div style="width:100%; height:80%">
<textarea id="TextareaLog" style="width:100%; height:100%"></textarea>
</div>
<script language="javascript" type="text/javascript">
var ForAppending = 8; // 追加模式
var ForReading = 1; // 读取模式
var ForWriting = 2; // 写入模式var fso = new ActiveXObject("Scripting.FileSystemObject"); // 文件系统
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // http访问
var textareaLog = document.getElementById("TextareaLog"); // 日志文本框
var textUsername = document.getElementById("TextUsername"); // 用户名
var textPassword = document.getElementById("TextPassword"); // 密码
var textDestuser = document.getElementById("TextDestuser"); // 目标用户/// <summary>
/// 将字符串追加到文本文件最后
/// </summary>
/// <param name="filename">文件名</param>
/// <param name="text">所要追加的字符串</param>
/// <returns>返回文本文件中的字符串</returns>
function AppendFileText(filename, text)
{
var istream = fso.OpenTextFile(filename, ForAppending, true);
if (!istream) return;
try
{
istream.write(text);
istream.Close();
}
catch (e)
{
}
}/// <summary>
/// 将字符串写到文本文件中
/// </summary>
/// <param name="filename">文件名</param>
/// <param name="text">所要追加的字符串</param>
/// <returns>返回文本文件中的字符串</returns>
function WriteFileText(filename, text)
{
var istream = fso.OpenTextFile(filename, ForWriting, true);
if (!istream) return;
try
{
istream.write(text);
istream.Close();
}
catch (e)
{
}
}/// <summary>
/// 添加日志
/// </summary>
/// <param name="text">日志文本</param>
function AppendLog(text)
{
if (textareaLog) textareaLog.value += text;
AppendFileText("log.txt", text);
}/// <summary>
/// 获得用户积分信息
/// </summary>
/// <param name="username">用户名</param>
/// <param name="password">密码</param>
/// <param name="destuser">目标用户</param>
/// <returns>返回构造的用户积分信息</returns>
function GetUserProfile(username, password, destuser)
{
var contentText =
'<?xml version="1.0" encoding="utf-8"?>\n' +
'<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">\n' +
' <soap12:Body>\n' +
' <GetUserProfile xmlns="http://www.csdn.net/">\n' +
' <identity>\n' +
' <username>' + username + '</username>\n' +
' <password>' + password + '</password>\n' +
' </identity>\n' +
' <username>' + destuser + '</username>\n' +
' </GetUserProfile>\n' +
' </soap12:Body>\n' +
'</soap12:Envelope>\n';
try
{
xmlhttp.open("post", "http://forum.csdn.net/OpenApi/forumapi.asmx", false);
xmlhttp.setRequestHeader("CONTENT-LENGTH", contentText.length);
xmlhttp.setRequestHeader("CONTENT-TYPE", "text/xml; charset=utf-8");
xmlhttp.send(contentText);
return xmlhttp.responseText;
}
catch (e)
{
return "";
}
}/// <summary>
/// 分析用户积分信息
/// </summary>
/// <param name="profileText">用户的XML信息</param>
/// <returns>返回构造的用户积分信息</returns>
function UserProfile(profileText)
{
profileText = profileText.replace(/\r\n/g, " ");
var re = /\<errId\>(.*?)\<\/errId\>/g;
if (re.exec(profileText)) this.errId = RegExp.$1; // 错误号 var re = /\<errInfo\>(.*?)\<\/errInfo\>/g;
if (re.exec(profileText)) this.errInfo = RegExp.$1; // 错误信息
var re = /\<point\>(.*?)\<\/point\>/g;
if (re.exec(profileText)) this.point = RegExp.$1; // 可用分
var re = /\<nickName\>(.*?)\<\/nickName\>/g;
if (re.exec(profileText)) this.nickName = RegExp.$1; // 昵称
var re = /\<username\>(.*?)<\/username\>/g;
if (re.exec(profileText)) this.username = RegExp.$1; // 用户名
var re = /\<techExpertPoint\>(.*?)\<\/techExpertPoint\>/g;
if (re.exec(profileText)) this.techExpertPoint = RegExp.$1; // 专家分 var re = /\<nonTechExpertPoint\>(.*?)\<\/nonTechExpertPoint\>/g;
if (re.exec(profileText)) this.nonTechExpertPoint = RegExp.$1; // 水分
}/// <summary>
/// 开始按钮点击事件
/// </summary>
function ButtonStartClick()
{
var userProfile = new UserProfile(
GetUserProfile(textUsername.value, textPassword.value, textDestuser.value));
if (userProfile.errId == 0)
{
textareaLog.value +=
"-------\r\n" +
"用户名:" + userProfile.username + "\r\n" +
"昵 称:" + userProfile.nickName + "\r\n" +
"专家分:" + userProfile.techExpertPoint + "\r\n" +
"水 分:" + userProfile.nonTechExpertPoint + "\r\n" +
"可用分:" + userProfile.point + "\r\n";
}
else AppendLog("错误:#" + userProfile.errId + "原因:" + this.errInfo + "\r\n");
}
</script>
</body>
</html>
那只是其中的FSO用到ACTIVEX而已,该成HTM 也可以用,只不过有提示
没问题能否给我示例呀。谢谢xiaojing7 ,谢谢你,不过你给我的那个有个错误。你在本机上测试了吗?
你说的是什么错误,查询不出来?(用户登陆,然后后面用户名)
页面报错? 可能是你禁用了ActiveX控件PS:我在本机测试过!谢谢