到 Google 资讯主页   
EasyJF首页   资料   源码   软件    论坛   网站    
   使用帮助    
    该信息为本站MyRSS系统缓存内容,部分图片及附件有可能无法正常使用.easyjf.comwww.blogjava.net无关,不对该信息负责.通过http://www.blogjava.net/fg112793897/archive/2007/08/30/141438.html访问该信息的原始内容.
页面功能  【加入收藏】 【推荐给朋友】 【字体:  】 【关闭】   
在用struts等编程时,中文转换成资源文件unicode码时的一个小程序
作者:peter2008 来源:www.blogjava.net  发布时间:2007-08-31 13:09:20.39

把以下代码保存成xxx.htm文件即可。

 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 2
 3<html>
 4<head>
 5<STYLE><!--
 6.button {
 7    font-size: 10.5pt; 
 8    color: #FFFFFF;
 9    background-color: #F58541;
10    border: 1px solid #BE5414;
11    clear: both;
12    height: 18px;
13    width: 45px;
14}

15.button1 {
16    font-size: 10.5pt; 
17    color: #FFFFFF;
18    background-color: #F58541;
19    border: 1px solid #BE5414;
20    clear: both;
21    height: 18px;
22    width: 135px;
23}

24-->
</STYLE>
25    <title>转换编码</title>
26<script language="JavaScript" type="text/javascript" >
27 function change(){
28 var onestring=document.form1(0).value;
29 if(onestring !=""){
30            var temp=escape(onestring);
31            var temp1=temp.replace(/\%/g,"\\")
32            document.form1(5).value=temp1
33 }
else{
34  alert("you must be forgetful,please fill in the blank!")
35 }

36}

37function reversechange(){
38 var onestring=document.form1(0).value;
39 if(onestring !=""){
40            var temp=onestring.replace(/\\/g,"%");
41            var temp1=unescape(temp);
42            document.form1(5).value=temp1;
43
44 }
else{
45  alert("you must be forgetful,please fill in the blank!")
46 }

47}

48function copyresult(){
49        var e=document.getElementById("result"); 
50        if(e.value==""){
51        window.clipboardData.setData("Text","告诉你个秘密,其实刚才什么也没复制上,哈哈哈哈,傻了吧!");
52          return;
53        }

54        e.select(); 
55        document.execCommand("Copy"); 
56    }
 
57
</script>    
58</head>
59<body>
60<form name="form1">
61 请您输入字符串: <input name="inputstring" type="text" size="100%" >&nbsp;&nbsp;<br><br><br>
62                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
63                  <input type="button" ONCLICK="change()" value="正向" class="button">  &nbsp;&nbsp;
64                  <input type="button" ONCLICK="reversechange()" value="反向"  class="button"> &nbsp;&nbsp;
65                  <input type="reset" onClick="clear"value="clear" class="button">&nbsp;&nbsp;
66                  <input type="button" onClick="copyresult();"value="点击复制转换结果" class="button1"><br><br><br>
67                  转换结果:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text"  value="" name="result" size="100%" readonly>
68
69</form>
70</body>
71</html>
72


peter2008 2007-08-30 16:52 发表评论

 
相关文章
 
页面功能  【加入收藏】 【推荐给朋友】 【字体:  】 【关闭】   


EasyJF.com 2006 隐私政策 使用EasyJF前必读