日期:2014-05-16  浏览次数:20510 次

Javascript 汉字转首字母的拼音(支持多音字的选择)
这是html代码,保存为html格式的文件,将下面的js代码保存为hhh.js文件,注意:两个文件需放在同一级目录、
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
		<script text="text/javascript" src="hhh.js" charset="GBK"></script>
		<style type="text/css">
table,td {
	border: 1px solid #CC6600;
	border-collapse: collapse;
	font-size: 12px;
}

#tit {
	font-size: 24px;
}

#divResult {
	border: 1px solid #CC6600;
	font-size: 14px;
	display: none;
	letter-spacing: 2px
}

.divDan {
	background-color: #FFCC99
}

.divShuang {
	background-color: #FFFFEE;
	font-size: 14px;
}
</style>
	</head>
	<body>
		<form name="form1">
			<table width="800" cellspacing="0" cellpadding="8" align="center">
				<tr>
						<td colspan="2">

								<center><a href="http://www.longhuiwang.com/read.php?tid=36&ds=1&page=1&toread=1#tpc">Javascript 汉字转首字母的拼音(支持多音字的选择)</a> <br>
								希望各位高手帮我想想为什么我的网站不被搜索引擎收录!
								
								<a href="mailto:xiangqian0505@163.com">给我留言</a></center>
						</td>
				</tr>
				<tr>
					<td align="right">
						程序测试:
					</td>
					<td>
						<span>请输入中文字符串:</span>
						<input type="text" id="txtChinese" size="20" value=""
							onblur="query()" />
							<span>拼音码:</span>
						<select name="select11" id="select11" style="width: 150px;">
							<option />
						</select>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>

?

Javascript代码:
// 汉字拼音首字母列表 本列表包含了20902个汉字,用于配合 ToChineseSpell
//函数使用,本表收录的字符的Unicode编码范围为19968至40869, XDesigner 整理
var strChineseFirstPY = "YDYQSXMWZSSXJBYMGCCZQPSSQBYCDSCDQLDYLYBSSJGYZZJJFKCCLZDHWDWZJLJPFYYNWJJTMYHZWZHFLZPPQHGSCYYYNJQYXXGJHHSDSJNKKTMOMLCRXYPSNQSECCQZGGLLYJLMYZZSECYKYYHQWJSSGGYXYZYJWWKDJHYCHMYXJTLXJYQBYXZLDWRDJRWYSRLDZJPCB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