网站SEO优化教程|技术分享|源码分享

本博客文章均是作者原创,记录码砖的点点滴滴,不介意搬砖,希望大家转载注明出处,感谢ing……




HTML转JS源码


 2020-05-19 19:52:45  浏览量:(59)   标签: HTML转JS 




预览图:

200519195547.png

HTML转JS源码:

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>HTML转JS</title><style>body{ margin:0; text-align:center}textarea{ margin:0; width:60%; height:200px;}

</style></head><body>



<p style='color: #C00;margin-top:30px;'><textarea id="z_html" placeholder="请输入要转换的HTML..." onload="this.value=''" type="text"></textarea> </p>



<input id="zjs" type='button' style=' width:200px; height:60px; color: #FFF; background-color:#C30; font-size:20px' value='转JS' />

<input id="zhtml" type='button' style=' width:200px; height:60px; color: #FFF; background-color:#C30; font-size:20px' value='转HTML' />



<input id = "qingkong" type='button' style=' width:200px; height:60px; color: #FFF; background-color:#C30; font-size:20px' value='清空文本' />



<p style='color: #C00;'><textarea id="z_js" placeholder="转换后的JS..." onload="this.value=''" type="text"></textarea> </p>



<script>

  document.getElementById("zjs").addEventListener("click", function(){

    change();

  });

  document.getElementById("zhtml").addEventListener("click", function(){

    rechange();

  });

  document.getElementById("qingkong").addEventListener("click", function(){

    document.getElementById('z_html').value="";

	document.getElementById('z_js').value="";

  });

     function rechange(){

     document.getElementById('z_js').value=document.getElementById('z_html').value.replace(/document.writeln\("/g,"").replace(/"\);/g,"").replace(/\\\"/g,"\"").replace(/\\\'/g,"\'").replace(/\\\//g,"\/").replace(/\\\\/g,"\\")

     }

     function change(){

     document.getElementById('z_js').value="document.writeln(\""+document.getElementById('z_html').value.replace(/\\/g,"\\\\").replace(/\\/g,"\\/").replace(/\'/g,"\\\'").replace(/\"/g,"\\\"").split('\n').join("\");\ndocument.writeln(\"")+"\");"

     }

</script>

</body>

</html>


如文章内容失效请联系作者更新,感谢ing,如有任何疑问点击网站提问按钮;

本文由【日韩赶SEO】原创,转载请注明出处,违者必究:http://4asport.com/post/76.html

提问 刷新 ^

友情链接:A5源码

Copyright ?2019 【日韩赶SEO】京ICP备25252500号