点击这里给我发消息 点击这里给我发消息

实现对文字自动排版的网页特效

添加时间:2011-9-1
    相关阅读: 网页 JavaScript 系统
<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> 本文作者:未知
咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册