如何获得网页内容的字符数 <script language="javascript">function window.onload(){ alert(document.fileSize);}</script> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <input type="button" value="显示字数" onclick="javascript:alert(document.body.innerText);alert(document.body.innerText.length)"> 向onestab()请教,能否不用按钮,当打开网页时在网页上自动显示字数 <body onload="window.status=document.body.innerText.length">向onestab()请教,能否不用按钮,当打开网页时在网页上自动显示字数 向qiushuiwuhen(秋水无恨)问好,能否将显示的数字放在网页中的任何位置?谢了。 onestab(),按你的方法,如何避免将空格和回车计算到字数里? <BODY><p>word count:<span id=wordcount></span></p>.......................<script>str = document.body.innerText;var s,len;s = len = str.length;for(var i=0; i<len;i++){ c = str.charAt(i); if(c=="\n" || c==" " || c=="\t") s--;}wordcount.innerText = s;</script></BODY> <BODY><p>word count:<span id=wordcount></span></p>.......................<script>str = document.body.innerText;wordcount.innerText = str.replace(/\s/g,"").length;</script></BODY> PFPF, 还是qiushuiwuhen(秋水无痕) 的方法快!!! 谢了楼上两位,的确是qiushuiwuhen(秋水无痕)的方法快 getJson(),回调函数不执行。 javascript如何调用系统的字体选择器,就像调用系统调色板一样. 多重数组循环 如果用javascript区别IE9和IE8 javascript是面向对象的嘛? 小弟最近在学习学习ASP,关于一段JS从数据库调出数据(10万火急) 一个很简单的网页设计,大家帮忙看看,谢谢了^_^ 如何把一个文本框动态的添加到一个层里 做向上向下按钮,weidegong(weidegong)帮忙拉(100分) 如何在打印页面时,屏蔽掉打印的按钮? 关于button的显示文本 这样的css样式怎么写?
document.body.innerText.length">
向onestab()请教,能否不用按钮,当打开网页时在网页上自动显示字数
<p>word count:<span id=wordcount></span></p>
.......
.......
.......
.
.
<script>
str = document.body.innerText;
var s,len;
s = len = str.length;
for(var i=0; i<len;i++){
c = str.charAt(i);
if(c=="\n" || c==" " || c=="\t") s--;
}
wordcount.innerText = s;
</script>
</BODY>
<p>word count:<span id=wordcount></span></p>
.......
.......
.......
.
.
<script>
str = document.body.innerText;
wordcount.innerText = str.replace(/\s/g,"").length;
</script>
</BODY>