当前位置: 代码迷 >> HTML/CSS >> HTML TO JavaScript 变换
  详细解决方案

HTML TO JavaScript 变换

热度:452   发布时间:2012-10-07 17:28:51.0
HTML TO JavaScript 转换
<html>
<head>
<title>HTML TO JavaScript 转换</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div class="menu_head">HTML TO JavaScript 转换</div>
<div class="content">
<div>请在下边输入HTML代码:</div>
<div>
<textarea name="htmlcource" style="width:99%" rows="15" id="oSource" onpropertychange="change()" onChange="change()"></textarea>
</div>
<BR />
<div>以下为经过转换以后的JavaScript代码:</div>
<div>
<textarea name="jscode" style="width:99%" rows="15" id="oResult" title="双击复杂代码" ondblclick='this.select();oResult.createTextRange().execCommand("Copy")'></textarea>
</div>
</div>
<SCRIPT LANGUAGE="JavaScript">
<!--
function change()
{
oResult.value="document.writeln(\""+oSource.value.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\'/g,"\\\'").replace(/\"/g,"\\\"").split('\r\n').join("\");\ndocument.writeln(\"")+"\")"
}
//-->
</SCRIPT>

</body>
</html>


详细出处参考:http://www.jb51.net/article/157.htm
  相关解决方案