数据载入中,请稍等...
http://blog.gz-auto.com/
数据载入中,请稍等...
博客公告
数据载入中,请稍等...
时间记忆
数据载入中,请稍等...
博客登陆
数据载入中,请稍等...
最新日志
数据载入中,请稍等...
最新评论
数据载入中,请稍等...
最新留言
数据载入中,请稍等...
博客相册
博客好友
数据载入中,请稍等...
友情连接
博客统计
数据载入中,请稍等...
半角<=>全角互转函数[JS版VBS版] | 2007-1-22 12:50:00
<script type="text/javascript">
function DBC2SBC(str,flag) {
var i;
var result='';
if (str.length<=0) {alert('字符串参数出错');return false;}
for(i=0;i<str.length;i++)
{ str1=str.charCodeAt(i);
if(str1<125&&!flag)
result+=String.fromCharCode(str.charCodeAt(i)+65248);
else
result+=String.fromCharCode(str.charCodeAt(i)-65248);
}
return result;
}
//示例:
alert(DBC2SBC("AAabc",0));
document.write(DBC2SBC("abcdefg",0))
</script>
<input type=text value="abcdefg" id=txt><input type=button value="变" onclick=txt.value="/blog/DBC2SBC(txt.value)>"
<script type="text/vbscript" language="vbscript">
function DBC2SBC(str,flag)
dim i
if len(str)<=0 then
msgbox '字符串参数出错'
exit function
end if
for i=1 to len(str)
str1=asc(mid(str,i,1))
if str1>0 and str1<=125 and not flag then
dbc2sbc=dbc2sbc&chr(asc(mid(str,i,1))-23680)
else
dbc2sbc=dbc2sbc&chr(asc(mid(str,i,1))+23680)
end if
next
end function
'示例:
alert(dbc2sbc("AB",1))
</script>
function DBC2SBC(str,flag) {
var i;
var result='';
if (str.length<=0) {alert('字符串参数出错');return false;}
for(i=0;i<str.length;i++)
{ str1=str.charCodeAt(i);
if(str1<125&&!flag)
result+=String.fromCharCode(str.charCodeAt(i)+65248);
else
result+=String.fromCharCode(str.charCodeAt(i)-65248);
}
return result;
}
//示例:
alert(DBC2SBC("AAabc",0));
document.write(DBC2SBC("abcdefg",0))
</script>
<input type=text value="abcdefg" id=txt><input type=button value="变" onclick=txt.value="/blog/DBC2SBC(txt.value)>"
<script type="text/vbscript" language="vbscript">
function DBC2SBC(str,flag)
dim i
if len(str)<=0 then
msgbox '字符串参数出错'
exit function
end if
for i=1 to len(str)
str1=asc(mid(str,i,1))
if str1>0 and str1<=125 and not flag then
dbc2sbc=dbc2sbc&chr(asc(mid(str,i,1))-23680)
else
dbc2sbc=dbc2sbc&chr(asc(mid(str,i,1))+23680)
end if
next
end function
'示例:
alert(dbc2sbc("AB",1))
</script>
- 上一篇:将日期格式化为RFC822格式
- 下一篇:鼠标经过连接时显示图片和文字提示的简单代码
超音速工作室 版权所有