|
热门文章 |
|
|
|
相关文章 |
|
没有相关文章 |
|
|
实现对文字自动排版的网页特效 |
来源:建站学 更新时间:2009/6/14 7:27:13 阅读次数:
字体:[大 中 小大 中 小大 中 小] 我要投稿 |
<html> <HEAD> <TITLE>自动排版工具-www.jzue.com</TITLE> <STYLE type=text/css> <!-- body {font-size:10pt} td {font-size:10pt} --> </STYLE> <SCRIPT language=JavaScript type=text/JavaScript> function format() { var body = "\n"+document.getElementById("thebody").value; body = body.replace(/ | /ig,""); body = body.replace(/\r\n/ig,"\n"); body = body.replace(/\n\n/ig,"\n"); body = body.replace(/\n\n/ig,"\n"); body = body.replace(/\n\n/ig,"\n"); body = body.replace(/\n\n/ig,"\n"); body = body.replace(/\n/ig,"\n\n "); body = body.replace("\n\n",""); body = body.replace(/\/g,""); body = body.replace(/\/g,""); body = body.replace(/\./g,"。"); body = body.replace(/,/g,","); body = body.replace(/:/g,":"); body = body.replace(/;/g,";"); body = body.replace(/\?/g,"?"); document.getElementById("thebody").value=body; } function format2() { //清除空行 var body = "\n"+document.getElementById("thebody").value; body = body.replace(/ | /ig,""); body = body.replace(/\r\n/ig,"\n"); body = body.replace(/\n\n/ig,"\n"); body = body.replace(/\n\n/ig,"\n"); body = body.replace(/\n\n/ig,"\n"); body = body.replace(/\n\n/ig,"\n"); body = body.replace(/\n/ig," \n"); body = body.replace("\n\n","\n"); document.getElementById("thebody").value=body; } /////////////////////////////////////////////////点击复制 function MM_goToURL() { //v3.0 var i, args=MM_goToURL.arguments; document.MM_returnValue = false; for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'"); } function JM_cc(ob){ var obj=MM_findObj(ob); if (obj) { obj.select();js=obj.createTextRange();js.execCommand("Copy");} } function MM_findObj(n, d) { //v4.0 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && document.getElementById) x=document.getElementById(n); return x; } //////////////////////////////////////////////////////查找与替换 function findText(oTextArea,oInput){ var rng=oTextArea.createTextRange() var bFlag=rng.findText(oInput) rng.select(); return bFlag; } function replaceText(oTextArea,toReplace){ oTextArea.focus(); var rng=document.selection.createRange(); if(rng.text.length<=0)return; rng.text=toReplace; } function reAll(oTextArea,toReplace){ while(findText(thebody,input1.value)) replaceText(thebody,input2.value); } </SCRIPT> </HEAD> <BODY> <P>自动排版工具</P> <P> <TABLE style="BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 borderColor=#111111 cellPadding=0 width="100%" bgColor=#ffffff height=532> <TBODY></TBODY></TABLE> <TABLE border=0 width="100%"> <P></P> <TBODY> <TR> <TD><INPUT class=button title=仅用于删除文章内多余空行及空格 onclick=javascript:format2() value=消除格式 type=button name=body1> <INPUT class=button title=系统自动排版 onclick=javascript:format() value=自动排版 type=button name=body> </FONT><INPUT onclick="JM_cc('thebody')" value=复制到剪贴板 type=button name=Button> 查找内容<INPUT name=input1> 替换成<INPUT name=input2> <INPUT class=button title=全部替换 onclick=javascript:reAll() value=全部替换 type=button name=body2> </TD></TR></TBODY></TABLE><TR><TD bgcolor="#FAFAFA" height="80%" width="100%"> <P><TEXTAREA style="BORDER-BOTTOM: #808080 1px dotted; BORDER-LEFT: #808080 1px dotted; COLOR: #494949; BORDER-TOP: #808080 1px dotted; BORDER-RIGHT: #808080 1px dotted" id=thebody rows=30 cols=120></TEXTAREA> </P> <P>说明:1、自动排版可实现段前自动加两个全角空格,每段隔一行,文中空格自动消除。 2、消除格式是指去除段前空格及段间空行。</P></TD></TR></TABLE></FORM></BODY> </html> |
上一篇文章: 设为首页、加入收藏代码大全下一篇文章: JavaScript实现执行完某一操作后跳转到某一指定页面 |
|
|