帝国CMS实时显示当前文章内容的字数的代码
打开:./eadmin/admin/AddNews.php
找到:</body>
在上面加:
<script>document.addEventListener("DOMContentLoaded",function(){function u(e){let t=(e.innerText||e.textContent||"").trim().length,d=document.getElementById("word-count-display");if(!d){let n=document.querySelector('input[type="submit"][name="addnews"]');n&&(d=document.createElement("div"),d.id="word-count-display",d.style.marginLeft="20px",d.style.color="#666",d.style.display="inline-block",n.insertAdjacentElement("afterend",d))}d&&(d.textContent="文章字数:"+t+"字")}function m(){document.querySelectorAll("iframe").forEach(f=>{try{let e=f.contentDocument.querySelector(".cke_editable");e&&!e.dataset.listened&&(e.dataset.listened="true",u(e),["input","paste"].forEach(evt=>e.addEventListener(evt,()=>setTimeout(()=>u(e),10))))}catch{}})}setInterval(m,1e3)});</script>
样式如下:
帝国CMS实时显示当前文章内容的字数的代码
版权申明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
蓝大富博客 » 帝国CMS实时显示当前文章内容的字数的代码
蓝大富博客 » 帝国CMS实时显示当前文章内容的字数的代码
