用Javascript转换源代码
例子:
<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>
源代码如下:
<textarea style="width:500;height:200" name="n1">
例子:
<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>
</textarea><br>
<input type="button" onclick="txt=document.all.n1.value;hh()" value="转换">
<script>
txt="";txt2="";txt3="";num=0
function hh(){
document.all.n1.value=Math.floor(num/txt.length*100)+"%"
txt3=txt.charAt(num)
if(txt3 == " "){txt3=" "};if(txt3 == "&"){txt3="&"};if(txt3 == "\""){txt3="""};if(txt3 == "<"){txt3="<"};if(txt3 == ">"){txt3=">"}
txt2=txt2+txt3
num++;if(num != txt.length){setTimeout("hh()",1)};else{document.all.n1.value=txt2}
}
</script>