用hta与ajax实现的五笔字型编码查询工具

 更新时间:2007年03月10日 00:00:00   作者:  

存为hta文件,即可

复制代码 代码如下:

<html> 
<head> 
<title>五笔字型编码查询工具</title> 
<meta http-equiv="content-type" content="text/html;charset=gb2312" /> 

<HTA:Application 
    MaximizeButton="No" 
    Icon="http://www.w3cg.net/WuBi/wb.ico" 
    Id="WuBiApp"  
    SingleInstance="Yes"  
    ContextMenu="Yes" 
    Sysmenu="Yes" 
    WindowState="Normal"  
    Border="Thin"  
    MinimizeButton="Yes" 
    ApplicationName=""  
    Version="1.0"  
    InnerBorder="No" 
    Caption="Yes"  
    ShowinTaskBar="No"  
/> 

<style type="text/css"> 
<!-- 
body { background:#d4d0c8; } 
* { font-family:Arial,sans-serif;font-size:9pt;color:#333; } 
#main { width:100%;height:100%; } 
textarea { line-height:130%; } 
a:link,a:visited { text-decoration:none; } 
--> 
</style> 

<script language="javascript"> 
<!-- 

var url="http://www.w3cg.net/wubi/"; 
var btv1="您可以通过改变下拉列表框来选择你想要功能"; 
var btv2="谢谢分享,您可以点此提交这些汉字编码信息"; 
var btv3="如果您确定已经写好留言,请点此提交给作者"; 
var btv4="正在向服务器提交数据,请稍候。。。。。。"; 
var xmlhttp; 

try { 
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 

catch(e) { 
    alert("对不起,不能创建系统对象,请检查您的系统设置。   "); 
    xmlhttp=false; 


function trim(str){  
    str=str.replace(/^\s*/,""); 
    str=str.replace(/\s*$/,""); 
    return str;  


function window.onload() { 
    var awidth,aheight; 
    var swidth,sheight; 
    awidth= 600; 
    aheight= 300; 
    swidth= screen.width; 
    sheight= screen.height; 
    window.resizeTo(awidth,aheight); 
    var left,top; 
    left= (swidth-awidth)/2; 
    top= (sheight-aheight)/2; 
    window.moveTo(left,top); 
    document.getElementById("btsubmit").innerText=btv1; 
    if (xmlhttp) { 
        var rult=document.getElementById("result"); 
        rult.innerText="正在读取公告信息。。。"; 
        xmlhttp.open("get",url+"ResponseNews.asp?number="+Math.random(),true); 
        xmlhttp.send(); 
        xmlhttp.onreadystatechange=function() { 
            if (xmlhttp.readystate==4) { 
                if (xmlhttp.status==200) { 
                    rult.innerText=unescape(xmlhttp.responseText); 
                } 
                else { 
                    rult.innerText="公告读取失败,请检查网络设置并重试一次。"; 
                } 
            } 
        }                     
    } 


function ckeyword() { 
    var key=document.getElementById("keyword"); 
    if (key.value=="→ 请输入您要查询编码的汉字的拼音") { 
        key.innerText=""; 
    } 


function keywordblur() { 
    var key=document.getElementById("keyword"); 
    if (key.value=="") { 
        key.innerText="→ 请输入您要查询编码的汉字的拼音"; 
    } 


function modonchange() { 
    var sMod=document.getElementById("module"); 
    var key=document.getElementById("keyword"); 
    var rult=document.getElementById("result"); 
    var btsub=document.getElementById("btsubmit"); 
    switch(sMod.value) { 
        case "cxmod": 
            location.reload(); 
            break; 
        case "tjmod": 
            key.innerText="→ 您正在进行的是添加新编码信息操作"; 
            key.disabled=true; 
            var str; 
            str="提交新汉字编码信息的格式为:\n\n"; 
            str+="例,li,WGQJ,鸿鹄;\n\n"; 
            str+="其中\"例\"为要添加的汉字;\"li\"为该汉字的拼音;\"WGQJ\"为该汉字的五笔编码,建议使用大写字母;\"鸿鹄\"为您的名字,将会在用户查询时出现。"; 
            str+="如果有多条记录请用分号隔开,所有的标点符号请在英文状态下输入。\n\n"; 
            str+="向所有支持本工具完善的朋友致敬!"; 
            rult.innerText=str; 
            btsub.disabled=false; 
            btsub.innerText=btv2; 
            break; 
        case "lymod": 
            key.innerText="→ 您正在进行的是留言操作"; 
            key.disabled=true; 
            var astr; 
            astr="请告诉我您对本工具的任何意见和建议,或者,作者也愿分享你生活中的愉快和不愉快,记得来信或留言时请一并留下您的姓名、联系方式等信息,以便作者回复,谢谢!\n\n"; 
            astr+="作者姓名:贺  兵\n"; 
            astr+="网    名:十一狼,武陵狂生,飘萍生,等\n"; 
            astr+="QQ:112183883\n" 
            astr+="电子邮箱:112183883@163.com,112183883@qq.com\n"; 
            astr+="原籍地址:四川射洪\n"; 
            astr+="目前住址:浙江杭州  "; 
            rult.innerText=astr; 
            btsub.disabled=false; 
            btsub.innerText=btv3; 
            break; 
    } 


function searchkey() { 
    var key=document.getElementById("keyword"); 
    var rult=document.getElementById("result"); 
    if (key.value.length!=0) { 
        if (xmlhttp) { 
            xmlhttp.open("get",url+"Search.asp?py="+escape(trim(key.value))+"&numer="+Math.random(),true); 
            xmlhttp.onreadystatechange=function() { 
                if (xmlhttp.readystate==4) { 
                    if (xmlhttp.status==200) { 
                        rult.innerText=unescape(xmlhttp.responseText); 
                    } 
                    else { 
                        rult.innerText="查询过程出错,请检查网络设置并重试一次。"; 
                    } 
                } 
            //    else { 
            //        rult.innerText="正在查询中。。。"; 
            //    } 
            } 
            xmlhttp.send(); 
        } 
    } 


function btsubmitclick() { 
    var sMod=document.getElementById("module"); 
    var rult=document.getElementById("result"); 
    var btrv=document.getElementById("btsubmit"); 
    switch (sMod.value) { 
        case "tjmod": 
            btrv.disabled=true; 
            rult.disabled=true; 
            if (xmlhttp) { 
                var Rstr="newletter="+escape(rult.value); 
                xmlhttp.open("post",url+"Addnew.asp?number="+Math.random(),true); 
                xmlhttp.onreadystatechange=function() { 
                    if (xmlhttp.readystate==4) { 
                        if (xmlhttp.status==200) { 
                            rult.innerText=unescape(xmlhttp.responseText); 
                            btrv.innerText=btv2; 
                            btrv.disabled=false; 
                            rult.disabled=false; 
                        } 
                        else { 
                            alert("添加新编码过程出错,请检查网络设置并重试一次。   "); 
                            btrv.innerText=btv2; 
                            btrv.disabled=false; 
                            rult.disabled=false; 
                        } 
                    } 
                    else { 
                            btrv.innerText=btv4; 
                    } 
                } 
                xmlhttp.setRequestHeader("content-length",Rstr.length); 
                xmlhttp.setRequestHeader("content-type","application/x-www-form-urlencoded"); 
                xmlhttp.send(Rstr); 
            } 
            break; 
        case "lymod": 
            btrv.disabled=true; 
            rult.disabled=true; 
            if (xmlhttp) { 
                var Gstr="gstr="+escape(rult.value); 
                xmlhttp.open("post",url+"Guest.asp?number="+Math.random(),true); 
                xmlhttp.onreadystatechange=function() { 
                    if (xmlhttp.readystate==4) { 
                        if (xmlhttp.status==200) { 
                            rult.innerText=unescape(xmlhttp.responseText); 
                            btrv.innerText=btv3; 
                            btrv.disabled=false; 
                            rult.disabled=false; 
                        } 
                        else { 
                            alert("留言添加过程出错,请检查网络设置并重试一次。   "); 
                            btrv.innerText=btv3; 
                            btrv.disabled=false; 
                            rult.disabled=false; 
                        } 
                    } 
                    else { 
                            btrv.innerText=btv4; 
                    } 
                } 
                xmlhttp.setRequestHeader("content-length",Gstr.length); 
                xmlhttp.setRequestHeader("content-type","application/x-www-form-urlencoded"); 
                xmlhttp.send(Gstr); 
            } 
            break; 
    } 

//--> 
</script> 
</head> 

<body scroll="no"> 
    <div id="main"> 
        <fieldset style="width:100%;height:100%;text-align:left;"> 
        <form name="search" style="margin:10"> 
            <input type="text" id="keyword" value="→ 请输入您要查询编码的汉字的拼音" size="40" style="color:#789" onfocus="ckeyword()" onblur="keywordblur()" onkeyup="searchkey()" /> 
            <select id="module" onchange="modonchange()"> 
                <option value="cxmod">查询模式</option> 
                <option value="tjmod">添加模式</option> 
                <option value="lymod">留言模式</option> 
            </select> 
            <br/> 
            <textarea rows="10" cols="100" id="result" style="margin-top:5px;"></textarea> 
            <br/> 
            <input type="button" id="btsubmit" disabled="true" style="width:310px;margin-top:7px" onclick="btsubmitclick()">&nbsp; 
            <a href="#" onclick="location.reload()">刷新</a> 
        </form> 
        </fieldset> 
    </div> 
</body> 

</html>

相关文章

最新评论