标题: 软景目录多列显示方法 [打印本页]
作者: 无极 时间: 2012-6-12 01:43
标题: 软景目录多列显示方法
出差在外,发个帖也方便。过几天又有事!
软景生成的目录默认是一列,不好改成多列的!想了一种改成多列显示的方法。原理还是利用类此HP那样生成一个数组来实现。具体过程如下。
用软景自带的模板做个例子
一、生成pages数组
这是软景生成后,默认的效果图
[attach]58065[/attach]
其默认的整个网页代码如下执行下面的EE脚本生成pages数组,并插入到网页头处
注意:如果没有插入到网页中,请自己粘贴到合适的位置
这是生成数组的EE脚本- var str="<script language=\"javascript\">"+"\n";
- str+="var pages=new Array();"+"\n";
- var reg=new RegExp("<a href=(.*\.htm)[^#].*>(.*)<\/a>","gmi")
- document.selection.StartOfDocument();
- document.selection.SelectAll();
- var txt = document.selection.Text;
- var aReturn;
- var i=0;
- while(1){
- aReturn= reg.exec(txt);
- if(aReturn!=null)
- {
- //去掉字符串本身自带的"
- aReturn[1]=aReturn[1].replace(/\"/gi,"");
- aReturn[2]=aReturn[2].replace(/\"/gi,"");
- str+="pages["+i+"]=[\""+aReturn[1] +"\",\""+aReturn[2]+"\"];"+"\n";
- i++;
- }
- else
- {
- break;
- }
- }
- str+="<\/script>";
- var found=document.selection.Replace("<\/head>",str+"\n"+"<\/head>",eeReplaceAll);//在网页头部插入pages数组
- if(found==0)//没有找到网页头结束标签,提醒用户自行粘贴
- {
- clipboardData.setData( "Text", str);
- alert("pages数组已经复制到剪贴板,请自行粘贴到文档的合适位置");
- }
复制代码 生成的数组如下- <script language="javascript">
- var pages=new Array();
- pages[0]=["mydoc000.htm","第〇〇一节"];
- pages[1]=["mydoc001.htm","第〇〇二节"];
- pages[2]=["mydoc002.htm","第〇〇三节"];
- pages[3]=["mydoc003.htm","第〇〇四节"];
- pages[4]=["mydoc004.htm","第〇〇五节"];
- pages[5]=["mydoc005.htm","第〇〇六节"];
- pages[6]=["mydoc006.htm","第〇〇七节"];
- pages[7]=["mydoc007.htm","第〇〇八节"];
- pages[8]=["mydoc008.htm","第〇〇九节"];
- pages[9]=["mydoc009.htm","第〇一〇节"];
- pages[10]=["mydoc010.htm","第〇一一节"];
- pages[11]=["mydoc011.htm","第〇一二节"];
- pages[12]=["mydoc012.htm","第〇一三节"];
- pages[13]=["mydoc013.htm","第〇一四节"];
- pages[14]=["mydoc014.htm","第〇一五节"];
- pages[15]=["mydoc015.htm","第〇一六节"];
- pages[16]=["mydoc016.htm","第〇一七节"];
- pages[17]=["mydoc017.htm","第〇一八节"];
- pages[18]=["mydoc018.htm","第〇一九节"];
- pages[19]=["mydoc019.htm","第〇二〇节"];
- pages[20]=["mydoc020.htm","第〇二一节"];
- pages[21]=["mydoc021.htm","第〇二二节"];
- pages[22]=["mydoc022.htm","第〇二三节"];
- pages[23]=["mydoc023.htm","第〇二四节"];
- pages[24]=["mydoc024.htm","第〇二五节"];
- </script>
复制代码
作者: 无极 时间: 2012-6-12 02:09
此时目录如下
[attach]58066[/attach]
附件是用师士传说做得例子,和相关关的脚本
表格样式比较难看,这个自己去修改吧。看球去了
作者: 健少 时间: 2012-6-12 13:39
好贴!进来瞅瞅~
作者: 梦千寻 时间: 2012-6-12 19:53
又见高手出动啦!
作者: 无极 时间: 2013-6-24 21:45
最近看软景书,用这个整理下
欢迎光临 (http://zasq.com/) |
Powered by Discuz! X3.2 |