html和js的互相转化
<!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=gb2312" />
<title>HTML与JS互转工具</title>
</head>
<script language="javascript">
function change(){
txt.value="document.writeln(\""+txt.value.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\'/g,"\\\'").replace(/\"/g,"\\\"").split('\r\n').join("\");\ndocument.writeln(\"")+"\")"
}
function rechange(){
txt.value=txt.value.replace(/document.writeln\("/g,"").replace(/"\);/g,"").replace(/\\\"/g,"\"").replace(/\\\'/g,"\'").replace(/\\\//g,"\/").replace(/\\\\/g,"\\")
}
</script>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">请在文本框中输入要转换的代码
<textarea id="txt" rows="30" cols="100" value=''></textarea></td>
</tr>
<tr>
<td height="15" class="maincontent2"><div align="center">
<input type="button" onClick="change()" name="Submit2" value="HTML转JS">
<input type="button" onClick="rechange()" name="Submit1" value="JS转HTML">
</div></td>
</tr>
</table>
</body>
</html>