<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Javascript格式化工具</title> <mce:script type="text/javascript"><!-- window.onload = function() { var c = document.forms[0].content; c && c.setSelectionRange && c.setSelectionRange(0, 0); c && c.focus && c.focus(); } function do_js_beautify() { document.getElementById('beautify').disabled = true; var js_source = document.getElementById('content').value.replace(/^/s+/, ''); var indent_size = document.getElementById('tabsize').value; var indent_char = ' '; var preserve_newlines = document.getElementById('preserve-newlines').checked; if (indent_size == 1) { indent_char = '/t'; } if (js_source && js_source[0] === '<') { document.getElementById('content').value = style_html(js_source, indent_size, indent_char, 80); } else { document.getElementById('content').value = js_beautify(js_source, {indent_size: indent_size, indent_char: indent_char, preserve_newlines:preserve_newlines}); } document.getElementById('beautify').disabled = false; return false; } // --></mce:script> <mce:script type="text/javascript" src="beautify.js" mce_src="beautify.js" ></mce:script> <mce:script type="text/javascript" src="HTML-Beautify.js" mce_src="HTML-Beautify.js" ></mce:script> <mce:style type="text/css"><!-- form { margin: 0 10px 0 10px; } textarea { width: 100%; height: 320px; border: 1px solid #ccc; padding: 3px; } h1 { font-family: "trebuchet ms", arial, sans-serif; font-weight: normal; font-size: 28px; color: #666; margin-bottom: 15px; border-bottom: 1px solid #666; } select { width: 19%; } button { width: 100px; cursor: pointer; } label { font-family: arial, helvetica, sans-serif } textarea, pre, span.code { font-family: terminus, consolas, "lucida console", "courier new", courier, monospace; font-size: 12px; } pre { margin: 20px 0; color: #777; } div#bottom { color: #333; font-family: arial, helvetica, sans-serif; font-size: 90%; border-top: 1px solid #ccc; margin: 20px; } --></mce:style><style type="text/css" mce_bogus="1">form { margin: 0 10px 0 10px; } textarea { width: 100%; height: 320px; border: 1px solid #ccc; padding: 3px; } h1 { font-family: "trebuchet ms", arial, sans-serif; font-weight: normal; font-size: 28px; color: #666; margin-bottom: 15px; border-bottom: 1px solid #666; } select { width: 19%; } button { width: 100px; cursor: pointer; } label { font-family: arial, helvetica, sans-serif } textarea, pre, span.code { font-family: terminus, consolas, "lucida console", "courier new", courier, monospace; font-size: 12px; } pre { margin: 20px 0; color: #777; } div#bottom { color: #333; font-family: arial, helvetica, sans-serif; font-size: 90%; border-top: 1px solid #ccc; margin: 20px; }</style> </head> <body> <h1>格式化 Javascript---<a href="http://www.css88.com/" mce_href="http://www.css88.com/" class="STYLE2">返回前端开发首页</a></h1> <p>1.该工具主要用于将去掉空格的代码或者压缩成一行的格式化,方便阅读,不能将加密过的js还原破解;<br /> 2.粘贴你代码到文本区域并点击格式化按钮就可以将代码格式化;支持jQuery,YUI等框架<br /> 3.JavaScript 压缩工具<a href="http://www.css88.com/tool/ysjs/" mce_href="http://www.css88.com/tool/ysjs/" target="_blank">http://www.css88.com/tool/ysjs/</a> </p> <form method="post" action="?"> <textarea rows="30" cols="30" name="content" id="content">/* 粘贴你代码到这里并点击格式化按钮 */ /* 例如格式化以下这段代码 */ if('this_is'==/an_example/){do_something();}else{var a=b?(c%d):e[f];} 格式化 用“tab”键缩进缩进2个空格缩进4个空格缩进6个空格 保存现有的换行符? 由http://jsbeautifier.org/ 提供技术支持