firefox 表格换行 使用问题,请教 echo " <script language='javascript'>toBreakWord(4, 'content2'); </script>"; 放在while循环之后. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这样的只有一行的值符合要求,其余的仍然不变:您看是一下这个样子的吗?<?php}echo "<script language='javascript'>toBreakWord(4, 'content2');</script>";echo "</table>"; ?> document.getElementById 只能取得一个元素, 得用document.getElementsByName<script type="text/javascript">function toBreakWord(intLen, id){var obj=id;//alert(obj);var strContent=obj.innerHTML;//alert(strContent)var strTemp="";while(strContent.length>intLen){strTemp+=strContent.substr(0,intLen)+"<br>"; strContent=strContent.substr(intLen,strContent.length); }//alert(strTemp);//alert(strContent);strTemp+= strContent;obj.innerHTML=strTemp;}window.onload=function (what){if(arguments.length == 0) what='content2'; else what=arguments[0]; obj=document.getElementsByName(what); len=obj.length; for (i=0;i<len;i++){ toBreakWord(4,obj[i]); } }</script><body><table border=1><tr><td name="content2" id="content2">01234567890123456789</td><td name="content2" id="content2">wertyuioplkjhghjklzx</td></tr><tr><td name="content2" id="content2">01234567890123456789</td><td name="content2" id="content2">wertyuioplkjhghjklzx</td></tr></table></body> 首先感谢您的回复!按照您说的,我复制到本地测试一下,好像不行!结果应该是如下这样的:0123 | wert4567 | yuio8901 | plkj2345 | hghj6789 | klzx0123 | wert4567 | yuio8901 | plkj2345 | hghj6789 | klzxtoBreakWord(4,obj[i]);//没有起作用不知道哪里还得改一下,才行! 谢谢 <script language='javascript'>function toBreakWord(intLen, obj){ //var obj=document.getElementById(id); var strContent=obj.innerHTML; var strTemp=""; alert('1'); while(strContent.length > intLen) { strTemp+=strContent.substr(0,intLen)+"<br>"; strContent=strContent.substr(intLen,strContent.length); } strTemp+= strContent; obj.innerHTML=strTemp;}window.onload = function(){ var divObj = document.getElementsByTagName('td'); for(var i=0; i< divObj.length; i++) { //alert(divObj[i]); if(divObj[i].id == "content2") { toBreakWord(3, divObj[i]); } }}</script><table border='1' id="divTable"> <tr> <td name="content2" id="content2">01234567890123456789</td> <td name="content2" id="content2">wertyuioplkjhghjklzx</td> </tr> <tr> <td name="content2" id="content2">01234567890123456789</td> <td name="content2" id="content2">wertyuioplkjhghjklzx</td> </tr> <tr> <td name="content3" id="content3">01234567890123456789</td> <td name="content3" id="content3">wertyuioplkjhghjklzx</td> </tr></table>注意第三个<tr>里面的没有改. <script type="text/javascript">function toBreakWord(intLen, id){var obj=id;var strContent=obj.innerHTML;var strTemp="";while(strContent.length>intLen){strTemp+=strContent.substr(0,intLen)+"<br>"; strContent=strContent.substr(intLen,strContent.length); }strTemp+= strContent;obj.innerHTML=strTemp;}window.onload=function (){ var obj=document.getElementsByName('content2'); var len=obj.length; for (i=0;i<len;i++){ toBreakWord(4,obj[i]); }}</script><body><table border=1><tr><td name="content2" id="content2">01234567890123456789</td><td name="content2" id="content2">wertyuioplkjhghjklzx</td></tr><tr><td name="content2" id="content2">01234567890123456789</td><td name="content2" id="content2">wertyuioplkjhghjklzx</td></tr></table></body> <script type="text/javascript">function toBreakWord(intLen, id){var obj=document.getElementById(id);var strContent=obj.innerHTML; var strTemp="";while(strContent.length>intLen){strTemp+=strContent.substr(0,intLen)+"<br>"; strContent=strContent.substr(intLen,strContent.length); }strTemp+= strContent;obj.innerHTML=strTemp;}</script><!--<div id="content2" >hello world</div><script language='javascript'>toBreakWord(4, 'content2');</script>--><?php$arr = array("0123456789","1234567890","2345678901");$array = array("helloworld","abcdefghigklmn","opqrstuvwxyz");foreach($arr as $key=>$value){ echo "<div id='content".$key."'>$value</div>"; echo "<script language='javascript'>toBreakWord(4, 'content".$key."');</script>"; echo "<hr>";}foreach($array as $key=>$value){ echo "<div id='cont".$key."'>$value</div>"; echo "<script language='javascript'>toBreakWord(4, 'cont".$key."');</script>"; echo "<hr>";}?> 请问如何实现客户端批量下载文件? 关于php调用shell脚本,脚本中部分命令不执行的问题 关于框架view如何实现的问题 帮我看一下 那位仁兄还保留有 《 VS.PHP for 2003 V2.0.1.2556 》 软件。。。。 php页面在显示时总是有“-->”和“<!--”这两个符号显示。如何去掉啊?>??? 一个头疼的SQL问题(mysql) 考勤分数统计(急用) 怎样用javascript实现这个功能? php和oracle问题! 求:PHP静态页分页策略和简单代码! 请教简单登录验证问题
?>
function toBreakWord(intLen, id){
var obj=id;
//alert(obj);
var strContent=obj.innerHTML;
//alert(strContent)
var strTemp="";
while(strContent.length>intLen){
strTemp+=strContent.substr(0,intLen)+"<br>";
strContent=strContent.substr(intLen,strContent.length);
}
//alert(strTemp);
//alert(strContent);
strTemp+= strContent;
obj.innerHTML=strTemp;
}
window.onload=function (what){
if(arguments.length == 0)
what='content2';
else
what=arguments[0];
obj=document.getElementsByName(what);
len=obj.length;
for (i=0;i<len;i++){
toBreakWord(4,obj[i]);
}
}
</script>
<body>
<table border=1>
<tr>
<td name="content2" id="content2">01234567890123456789</td>
<td name="content2" id="content2">wertyuioplkjhghjklzx</td>
</tr>
<tr>
<td name="content2" id="content2">01234567890123456789</td>
<td name="content2" id="content2">wertyuioplkjhghjklzx</td>
</tr>
</table>
</body>
4567 | yuio
8901 | plkj
2345 | hghj
6789 | klzx0123 | wert
4567 | yuio
8901 | plkj
2345 | hghj
6789 | klzxtoBreakWord(4,obj[i]);//没有起作用不知道哪里还得改一下,才行! 谢谢
<script language='javascript'>
function toBreakWord(intLen, obj)
{
//var obj=document.getElementById(id);
var strContent=obj.innerHTML;
var strTemp="";
alert('1');
while(strContent.length > intLen)
{
strTemp+=strContent.substr(0,intLen)+"<br>";
strContent=strContent.substr(intLen,strContent.length);
}
strTemp+= strContent;
obj.innerHTML=strTemp;
}
window.onload = function()
{
var divObj = document.getElementsByTagName('td');
for(var i=0; i< divObj.length; i++)
{
//alert(divObj[i]);
if(divObj[i].id == "content2")
{
toBreakWord(3, divObj[i]);
}
}
}
</script><table border='1' id="divTable">
<tr>
<td name="content2" id="content2">01234567890123456789</td>
<td name="content2" id="content2">wertyuioplkjhghjklzx</td>
</tr>
<tr>
<td name="content2" id="content2">01234567890123456789</td>
<td name="content2" id="content2">wertyuioplkjhghjklzx</td>
</tr>
<tr>
<td name="content3" id="content3">01234567890123456789</td>
<td name="content3" id="content3">wertyuioplkjhghjklzx</td>
</tr>
</table>注意第三个<tr>里面的没有改.
function toBreakWord(intLen, id){
var obj=id;
var strContent=obj.innerHTML;
var strTemp="";
while(strContent.length>intLen){
strTemp+=strContent.substr(0,intLen)+"<br>";
strContent=strContent.substr(intLen,strContent.length);
}
strTemp+= strContent;
obj.innerHTML=strTemp;
}
window.onload=function (){
var obj=document.getElementsByName('content2');
var len=obj.length;
for (i=0;i<len;i++){
toBreakWord(4,obj[i]);
}
}
</script>
<body>
<table border=1>
<tr>
<td name="content2" id="content2">01234567890123456789</td>
<td name="content2" id="content2">wertyuioplkjhghjklzx</td>
</tr>
<tr>
<td name="content2" id="content2">01234567890123456789</td>
<td name="content2" id="content2">wertyuioplkjhghjklzx</td>
</tr>
</table>
</body>
function toBreakWord(intLen, id){
var obj=document.getElementById(id);
var strContent=obj.innerHTML;
var strTemp="";
while(strContent.length>intLen){
strTemp+=strContent.substr(0,intLen)+"<br>";
strContent=strContent.substr(intLen,strContent.length);
}
strTemp+= strContent;
obj.innerHTML=strTemp;
}
</script>
<!--
<div id="content2" >hello world</div>
<script language='javascript'>toBreakWord(4, 'content2');</script>
--><?php
$arr = array("0123456789","1234567890","2345678901");
$array = array("helloworld","abcdefghigklmn","opqrstuvwxyz");foreach($arr as $key=>$value){
echo "<div id='content".$key."'>$value</div>";
echo "<script language='javascript'>toBreakWord(4, 'content".$key."');</script>";
echo "<hr>";
}foreach($array as $key=>$value){
echo "<div id='cont".$key."'>$value</div>";
echo "<script language='javascript'>toBreakWord(4, 'cont".$key."');</script>";
echo "<hr>";
}?>