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时总是不成功,麻烦帮忙看看. PHP5怎么连接不上MySQL数据库? 关于PHPsession产生的临时文件删除不了 PHP中的 @ 是做什么的? socket发送mail的问题 php请教 IIS6 PHP503 提示找不到模块php_curl.dll,可明明文件就在那! 怎么用PHP收附件呢? 如何利用C语言开发PHP扩展函数! 求: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>";
}?>