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


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

 

本文作者:

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

 

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3