[转]静态新闻分页的js解决方案
今天看一个新闻网站,看到它的分页用的是JS读取内容字符串(这里用的XML节点内容)后处理,分页按自定义字数分,而且可以点击显示全部(即不分页方式浏览)
查看了它的源代码后提出了这个基本方法,感觉很好,粗略说一下前台调用方法及注意的地方:
附:cutarticle.js下载
查看了它的源代码后提出了这个基本方法,感觉很好,粗略说一下前台调用方法及注意的地方:
1
<div id="article"><!--正文正文内容显示区域(必须保留,后台js程序用到这个id)--></div>
2
<xml id="xmlArticle">
3
<Article>
4
<Info>
5
<Content>
6
<![CDATA[
7
<FONT face=Verdana><FONT face=Verdana>这里是新闻内容。(这里的xml的id,content节点后台也都用到,保留 )</FONT> ]]>
8
</Content>
9
</Info>
10
</Article>
11
</xml>
12
<script type="text/javascript">
13
//每页显示字数
14
PageSize=800;
15
//分页模式
16
flag=1;
17
</script>
18
<!--正文分页Js-->
19
<script type="text/javascript" src="cutarticle.js"></script>
20
<script type="text/javascript">
21
text_pagination(1);
22
</script>
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
附:cutarticle.js下载