基于web端去除空格小工具
读论文时,不时需要抓取PDF版的段落,可是复制到word的时候会出现很多空格,利用javascript强大的功能,几行命令实现了去除段落里的空格,实现如下:
<!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>地理位置坐标转换</title> <style media="screen"> body { margin: 0; padding: 0; font-size: 9pt; line-height: 1.5em; } #frame { width: 1200px; margin: 20px auto 10px; } #searchMap { margin: 0 0 10px; text-align: center; } # button { font-size: 9pt; border: 1px solid #ccc; } #txtRight,#txtLeft{ float: left; } #result{ margin-left: 200px; height: 200px; } #searchMap button:hover { background: #eef; } #vifix { text-align: center; } #vifix a { color: #f00; text-decoration: none; } #vifix a:hover { color: #f96; } </style> <script src="http://ditu.google.cn/maps?file=api&v=2&key=ABQIAAAAe3YR_oZq7RQougOHlEQYxRTrT8HRiYVHGz6s-cexYhuHznMTnBQJ3hrfCSvSmQ_Fqr80B62kDy8djA&sensor=true" type="text/javascript"></script> <script type="text/javascript"> window.g = {}; window.$ = function (id) { return document.getElementById(id) }; window.onload=function(){ function removeAllSpace(str) { return str.replace(/\s+/g, ""); } function trim(str) { return str.replace(/(^\s+)|(\s+$)/g, ""); } $("btn_go").onclick = function () { $("info").innerHTML=""; $("txtResult").value=""; var strSearch=$("txtSearch").value; for(var i=0;i<strSearch.length;i++){ $("txtResult").value=removeAllSpace(strSearch); } } } window.onunload = function () { GUnload(); } </script> </head> <body> <div id="frame"> <div id="searchMap"> <p>输入查询的点(用回车分开)</p><button id="btn_go">获取坐标</button><br/> <textarea id="txtSearch" rows="20" cols="40"/> </textarea> <div id="info"> </div> <div id="result"> <p>查询结果:</p> <div id="txtRight"><textarea id="txtResult" rows="10" cols="70" value="" /></textarea></div> <div id="unfound"> </div> </div> </div> <div id="map"> </div> <div id="vifix"> Powered by <a href="http://code.google.com/apis/maps/" target="_blank">Google Map API</a> / Created by <a href="http://vifix.cn%22%3evifix.cn%3c/a> </div> </div> </body> </html>