操作系统 程序设计 图形图像 媒体动画 机械电子 WEB开发 数据库 办公软件 路由技术 网络原理 网络架设 网络管理 认证培训
您的位置:计算机资讯网 >> WEB开发 >> JavaScript >> 技巧教程 -> html->javascript->jsp(out.println())
html->javascript->jsp(out.println())
2004-10-14 11:19:11


<%@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>

转自:不详 作者:未知 关闭
加入收藏 推荐给好友 打印本文
内容为网上收集,并不代表本站同意或者赞同其观点,如果有任何版权,内容问题,请联系本站,我们将在第一时间处理.
查询
关键字
搜索范围
热点专题
服务
计算机资讯网 | 联系方式 | 广告服务 | 意见留言 | 友情链接 | 网站地图 | 设为首页