我只会回答你的第2问,Javascript中text是有style属性的(不光它,还有好多元素都有样式的),用法如<input type=text style="color=red;background:yellow;border:1px,1px,1px,1px;">等等

解决方案 »

  1.   

    <html><head>
    <meta http-equiv="content-type" content="text/html; charset=gb2312">
    <meta name="author" content="chueh">
    <meta name="keywords" content="软件, 程序设计, 书签, 电子, 电脑, 计算机, 等级考试, 考试, 健身, 钱龙, 读物, 键盘, 自动, 链接, 太极, 气功, 鹊桥, software, program, computer, midi, taijiquan, books, DOS, Windows, ASP, JAVA, javascript">
    <title>全角转半角 - que.126.com</title>
    </head><script language="JavaScript">
    function o2c(fm){
    temp=repl(",",", ",document.replace.source.value)
    temp=repl("。",". ",temp)
    temp=repl("“",' "',temp)
    temp=repl("”",'" ',temp)
    temp=repl("/","/",temp)
    temp=repl("‘","'",temp)
    temp=repl("’","'",temp)
    //temp=repl("、",". ",temp)
    temp=repl("("," (",temp)
    temp=repl(")",") ",temp)
    temp=repl("*","*",temp)
    temp=repl("+","+",temp)
    temp=repl("-","-",temp)
    temp=repl(";","; ",temp)
    temp=repl(":",": ",temp)
    temp=repl("[","[",temp)
    temp=repl("]","]",temp)
    temp=repl("{","{",temp)
    temp=repl("}","}",temp)
    temp=repl("!","! ",temp)
    temp=repl("%","%",temp)
    temp=repl("#","#",temp)
    temp=repl("¥","$",temp)
    temp=repl("…","..",temp)
    temp=repl("—","--",temp)
    temp=repl("=","=",temp)
    temp=repl("·",".",temp)//A:%uFF21 A:%41
    //a:%uFF41 a:%61
    //0:%uFF10 0:%30for(var i=0;i<26;i++){
     temp=repl(unescape("%uff"+hex(33+i)),unescape("%"+hex(65+i)),temp);
     temp=repl(unescape("%uff"+hex(65+i)),unescape("%"+hex(97+i)),temp);
    }
    for(var i=0;i<10;i++)
     temp=repl(unescape("%uff"+hex(16+i)),unescape("%"+hex(48+i)),temp);document.replace.target.value=temp;
    return true;
    }function hex(d){
    h1=Math.round(d/16-0.5)
    h2=d-h1*16
    return ""+d2h(h1)+d2h(h2)
    }function d2h(d){
    if(d>9) h=unescape("%"+(d-10+41))
    else h=""+d
    return h
    }function repl(str1,str2,tmp){
    //str1=fm.replSour.value
    //str2=fm.replTarget.value
    //tmp=document.replace.source.value
    result=""
    fmLen=tmp.length
    if(fmLen=0) {  //无内容
     return '';
    }
    strEnd=tmp.indexOf(str1)
    str1Len=str1.length
    i=0
    while(strEnd>=0){
      i++
      result = result + tmp.substring(0,strEnd)+str2
      tmp=tmp.substring(strEnd+str1Len,tmp.length)
      strEnd=tmp.indexOf(str1)
    }
    result=result+tmp;
    if(document.replace.ul[0].checked) result=result.toLowerCase();
    if(document.replace.ul[1].checked) result=result.toUpperCase();
    return result;
    }
    </script>
    <center>
    <BODY onLoad="replace.source.focus()"><FORM NAME="replace">
    对结果进行:<input type=radio name=ul>大写->小写&nbsp;&nbsp;
    <input type=radio name=ul>小写->大写&nbsp;&nbsp;
    <input type=radio name=ul checked>大小写不转换&nbsp;<input type=reset value=" 清空内容 " onClick="replace.source.focus()"><br>
    <textarea name="source" rows=11 cols=80 onblur="o2c(this.form);return true">
    </textarea><br>
    <textarea name="target" rows=11 cols=80>
    </textarea>
    </FORM></center>
    </BODY></HTML>
      

  2.   

    unescape("%uff"+hex(33+i)),中的%uff 是干什么的呢??
    我其实是想实现这样的功能,就是:
    --------------------------
    在一个文本框里,maxlength为20,可以输入20个半角字符,但当输入的为全角字符的时候,只能输入10个.
    -------------------------
    但是现在我无论输入半角,全角,都可以输入20个!!!!
      

  3.   


    前面已经注解了:
    //A:%uFF21 A:%41
    //a:%uFF41 a:%61
    //0:%uFF10 0:%30这是他们的 escape 码,网页的一种加密编码,用unescape 进行解码。
    全角的字母数字前面都带有 %uFF 后面是有规律的数字,
    作者利用了这一点, 是匠心独具!方便之极。