根据汉字自动生成简拼和全拼

html文件代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
 <script src="pinyin.js" type="text/javascript"></script>
  
</head>

<body>
   <input id="Text1" type="text" />
  
    <div id="div1">
    </div>
   <span id="duoyinzi"></span>
 <script>
        document.getElementById("Text1").onkeyup = function()
        {
       var dyzshow=document.getElementById("duoyinzi");
           // document.getElementById("div1").innerHTML = pinyin.go(this.value,"quanping",dyzshow ,1);//例:张家界 zhangjiajie (全小写)
          // document.getElementById("div1").innerHTML = pinyin.go(this.value,"shouping",dyzshow ,1);//例:张家界 zjj (首小写)
          // document.getElementById("div1").innerHTML = pinyin.go(this.value,"quanping",dyzshow);//例:张家界 ZhangJiaJie (首字大写)
            document.getElementById("div1").innerHTML = pinyin.go(this.value,"shouping",dyzshow);//例:张家界 ZJJ (首字大写)

           }
    </script>
</body>
</html>

pinyin.js代码请点击下面链接,进行下载!

 http://pan.baidu.com/netdisk/singlepublic?fid=201681_3689420786

注:多音字测试:请打入“重”字!

如果汉字库中无所需汉字,请自行在汉字库的数组中进行添加!

来自于:http://blog.163.com/fengzhisha0914@126/blog/static/150314785201043011136271/

原文地址:https://www.cnblogs.com/liangxuru/p/3289304.html