<% dim ModuleName,InfoID,ChannelShortName,CorrelativeArticle,InstallDir,ChannelDir,Keyword,PageTitle,ArticleIntro,Articlecontent Keyword=stripHTML("WEB,#106avascript,应用,技巧") PageTitle=stripHTML("html-javascript-jsp(out.println())") ArticleIntro=stripHTML("") Articlecontent=stripHTML("<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>              <html>              <head> …") ModuleName = stripHTML("classical") InfoID = stripHTML("25238") ChannelShortName=stripHTML("文章") InstallDir=stripHTML("http://www.77169.com/") ChannelDir=stripHTML("classical") %> html-javascript-jsp(out.println()) - 华盟网 - http://www.77169.com
您现在的位置: 华盟网 >> 知识库 >> WEB开发 >> JavaScript >> 应用技巧 >> 正文

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

2005/8/29 作者:unknown 来源: unknown
导读 <% if len(ArticleIntro)<3 then Response.Write Articlecontent 'Response.Write "Articlecontent" else Response.Write ArticleIntro 'Response.Write "ArticleIntro" end if %>


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