职业IT人-IT人生活圈

 找回密码
 成为会员
搜索
查看: 2211|回复: 0

html-javascript-jsp(out.println())

[复制链接]
itxys 发表于 2008-3-4 21:54 | 显示全部楼层 |阅读模式
<%@LANGUAGE=\"VBSCRIPT\" CODEPAGE=\"936\"%>
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">
<title>html转js转jsp(或servlet)</title>
<style type=\"text/css\">
<!--
body {
font-size: 12px;
text-align: center;
margin: 0px;
border: none;
background-color: #CCCCCC;
}
-->
</style>
</head>

<body scroll=no>
<script>
function html2js(codestr){
var codes=codestr.split(\"\\n\");
var jscode=\"\";
var tcode=\"\";
for(var a=0;a<codes.length;a++){
if(codes[a].replace(/\\s+/,\"\")!=\"\"){
tcode=\"\";
tcode+=codes[a].replace(/\\\"/ig,\"\\\\\\\\\\\\\\\"\").replace(/(\\s+)</ig,\"<\").replace(/\\//ig,\"\\/\");
tcode=\"out.println(\\\"document.write(\\\\\\\"\"+tcode+\"\\\\\\\");\\\");\\n\";
jscode+=tcode.replace(/\\r/ig,\"\");
//alert(jscode);
}
}
jscode=\"out.println(\\\"<script language=\\\\\\\"javascript\\\\\\\">\\\");\\n\"+jscode+\"out.println(\\\"<\\/script>\\\");\";
return jscode;
}
function runcode(){
var mywin=window.open(\"\",\"测试窗口\",\"\")
mywin.document.open();
mywin.document.write(jscode.value);
mywin.document.close();
}
</script>
<textarea name=\"htmlcode\" style=\"width:100%\" rows=\"15\" id=\"htmlcode\"></textarea>
<input type=\"button\" name=\"Submit\" value=\" 转 换 \" onClick=\"jscode.value=html2js(htmlcode.value)\">
<input type=\"button\" name=\"Submit2\" value=\" 测 试 \" onClick=\"runcode()\">
<br>
<textarea name=\"jscode\" style=\"width:100%\" rows=\"15\" id=\"jscode\"></textarea>
<br>
</body>
</html>
您需要登录后才可以回帖 登录 | 成为会员

本版积分规则

QQ|手机版|小黑屋|网站帮助|职业IT人-IT人生活圈 ( 粤ICP备12053935号-1 )|网站地图
本站文章版权归原发布者及原出处所有。内容为作者个人观点,并不代表本站赞同其观点和对其真实性负责,本站只提供参考并不构成任何投资及应用建议。本站是信息平台,网站上部分文章为转载,并不用于任何商业目的,我们已经尽可能的对作者和来源进行了通告,但是能力有限或疏忽造成漏登,请及时联系我们,我们将根据著作权人的要求立即更正或者删除有关内容。

GMT+8, 2024-5-15 13:03 , Processed in 0.164101 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表