码迷,mamicode.com
首页 > 其他好文 > 详细

守卫剑阁 物品代码 转换工具

时间:2016-11-07 01:47:23      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:normal   转换   ice   blocks   contract   http   var   .com   har   







技术分享
<p>
<style>
.btn {
    font-family: "tahoma", "宋体";
    font-size:12pt; color: #003399;
    border: 1px #003399 solid;
    color:#006699;
    border-bottom: #93bee2 1px solid;
    border-left: #93bee2 1px solid;
    border-right: #93bee2 1px solid;
    border-top: #93bee2 1px solid;
    background-color: #e8f4ff;
    cursor: hand;
    font-style: normal ;
    width:auto;
    height:40px;
    float:left;
}

.txt {
    font-family: "tahoma", "宋体";
    font-size:16pt; color: #003399;
    border: 1px #003399 solid;
    color:#006699;
    border-bottom: #93bee2 1px solid;
    border-left: #93bee2 1px solid;
    border-right: #93bee2 1px solid;
    border-top: #93bee2 1px solid;
    text-align: center;
    cursor: hand;
    font-style: normal ;
    width:auto;
    height:36px;
    float:left;
}

</style>

<input id="1" class="txt" type="text" /> 
<button class="btn" onclick="i2a()" type="button">数字转字符</button> 
<input id="2" class="txt" type="text" />
<br />
<br />
<br />
<input id="3" class="txt" type="text" /> 
<button class="btn" onclick="a2i()" type="button">字符转数字</button> 
<input id="4" class="txt" type="text" />
<script>

function i2a()
{
    //1919707494
    //726c6966
    //0x72 0x6c 0x69 ox66
    //r l i f
    var txt1 = document.getElementById("1")
    var txt2 = document.getElementById("2")
    txt2.value =null
    var dif = new Array(0)
    var x = (parseInt(txt1.value)).toString(16)

    

    for(var i=0;i<x.length;i+=2)
    {
        dif.push(parseInt(x.slice(i,i+2),16))
    }

    for (var i=0;i<dif.length;i++)
    {
        //
        txt2.value += String.fromCharCode(dif[i]);
    }
    //console.log(dif)
}

function a2i()
{
    //r l i f
    //0x72 0x6c 0x69 ox66
    //726c6966
    //1919707494
    var txt3 = document.getElementById("3")
    var txt4 = document.getElementById("4")
    txt4.value=null
    var dif = new Array(0)
    var x = txt3.value
    var y =""

    for(var i=0;i<x.length;i++)
    {
        //
        dif.push((x[i].charCodeAt()).toString(16))
    }
    
    for(var i=0;i<dif.length;i++)
    {
        //
        y += dif[i]
    }

    txt4.value = parseInt(y,16)
}
</script>
<br /><br /><br />
</p>
View Code

 

守卫剑阁 物品代码 转换工具

标签:normal   转换   ice   blocks   contract   http   var   .com   har   

原文地址:http://www.cnblogs.com/jhcla/p/6036752.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!