任意字符转换Ascii编码网页版
无聊写了一个将任意字符转换为ascii编码的页面,当输入字符串时,将自动转换成ascii编码,完整代码如下:
<!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=utf-8" />
<title>字符串转换Ascii</title>
</head>
<body>
<SCRIPT
LANGUAGE="JavaS
function showKeyCode()
{
var Str=document.characterCode.character.value;
var character;
var co
var msg = ""
for(var i=0;i<Str.length;i++)
{
}
document.characterCode.result.value=msg;
}
function CopyResult()
{
if(document.characterCode.result.value!="")
{
copy_clip(document.characterCode.result.value);
}
}
function
copy_clip(copy){
if (window.clipboardData){
window.clipboardData.setData("Text", copy);}
else if (window.netscape){
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var clip =
Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
if (!clip) return;
var trans =
Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
if (!trans) return;
trans.addDataFlavor('text/unicode');
var str = new Object();
var len = new Object();
var str =
Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
var copytext=copy;
str.da
trans.setTransferData("text/unicode",str,copytext.length*2);
var clipid=Components.interfaces.nsIClipboard;
if (!clip) return false;
clip.setData(trans,null,clipid.kGlobalClipboard);}
alert("复制成功!")
return false;
}
</script>
<style type="text/css">
<!--
#Main {
}
-->
</style>
<div id="Main">
<form name="characterCode">
请输入字符串:
<textarea name="character" cols="100" rows="5"
on
转换结果:
<br>
<textarea name="result" cols="100"
rows="5"></textarea>
<input
</form>
</div>
</body>
</html>
运行效果: