寒江雪 2019-03-15 09:49 采纳率: 0%
浏览 415

JS能实现后台统计新闻字数并输出到页面端吗?

最近做个新闻网站,想在网站后台利用JS函数统计新闻字数,并在前台页面输出值,能实现吗?
就是要在浏览器端“新闻字数”后面输出函数计算的字数值

网页代码如下:



{Stl.SiteName}







<!--头部包含文件-->
/stl:include
  <!--页面当前位置导航-->
  <div class="breadcrumb">
    <stl:location>
      <span class="nail"></span>
    </stl:location>
  </div>

  <div class="maincntwrapper1">
    <div class="part1 c">
      <div class="txtarea">
        <h2 class="title"><stl:content type="Title" ></stl:content></h2>
        <div class="subinfo c">
          <span class="author fl">作者:<stl:content type="Author"></stl:content></span>
          <span class="source fl">来源:<stl:content type="Source"></stl:content></span>
          <span class="update fl">时间: <stl:content type="AddDate" formatString="yyyy-MM-dd HH:mm:ss"></stl:content></span>
          <span class="click fl" >点击:<stl:content type="Hits" isDynamic="true"></stl:content></span>
        </div>
        <div class="txt" >
          <stl:content  type="Content"></stl:content>

        </div>     



        <div class="subinfo c" style="border-bottom:0 solid #000000; border-top: 1px solid #cccccc; text-align:right">
          <span style="margin-right:5px;" >**_新闻字数:_**</span>

                        <span style="margin-right:60px;">新闻录入:<stl:content type="AddUserName"></stl:content></span>
          <span>责任编辑:<stl:content type="LastEditUserName"></stl:content></span>


        </div>
      </div>
    </div>

    <div class="spacerB"></div>
  </div>
    </div> 

<!--底部包含文件-->
<stl:include file="/include/bottom.html"></stl:include>



  • 写回答

1条回答

  • 毕小宝 博客专家认证 2019-03-15 09:57
    关注

    这个需求不复杂,是可以的。
    首先,后台需要提供一个获取统计新闻字数的请求处理方法。
    其次,前端添加“新闻字数”点击事件,发送请求给后台获取统计字数,并回显在前端。
    你是用什么技术做的,搜下相关技术的基本用法。

    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题