利用FCKeditor打印分页符实现内容分页

« 返回上页作者:乔夫  分类: 网事悠游  日期:2008-2-21 at 15:48  

客户要求对文章内容进行分页,考虑了一下觉得判断字数或行数于实际运用起来都不大科学。所以,想通过添加分页标签来判断。因为系统采用的是FCKeditor编辑器,其本身工具栏上按钮就有一个“插入分页符”,用于打印页面时,强制打印机换页。分页符为不可见对像,生成的代码为:

<div style="page-break-after: always"><span style="display: none">&nbsp;</span></div>

所以,现成的,就用它作显示分页标签了,再写一小段代码就判断一下就ok!

article = "<p>11</p><div style=""page-break-after: always;""><span style=""display: none;"">&nbsp;</span></div><p>22</p><div style=""page-break-after: always;""><span style=""display: none;"">&nbsp;</span></div><p>33</p><div style=""page-break-after: always;""><span style=""display: none;"">&nbsp;</span></div><p>44</p>"

page = trim(request.querystring("page"))

function pages(content)
  newcontent = split(article,"<div style=""page-break-after: always;""><span style=""display: none;"">&nbsp;</span></div>")
  pagenumber = "第<a href='pages.asp?page=1'>1</a>页"
  for i = 0 to ubound(newcontent)
    p = i + 1
    if p > 1 then pagenumber = pagenumber & ",第<a href='pages.asp?page="&p&"'>" &p& "</a>页"
  next
  if page = "" or page = "1" then
    response.write newcontent(0)
   else
    response.write newcontent(page-1)
  end if
  if p > 1 then response.write pagenumber
end function

response.write pages(article)
更多分享

1 条评论  Trackback Url:http://ichov.com/web/using-fckeditor-print-tab-split-page.html/trackback

One Response to “利用FCKeditor打印分页符实现内容分页”

  1. [...] 利用FCKeditor打印分页符实现内容分页之二 [...]

有啥说啥 Leave a Reply