表中的神秘线条

时间:2014-05-22 01:21:45

标签: html line-breaks

[增订]。我有一个嵌套在另一个工作表中的表,直到有一天它出现在页面的下半部分。我检查了实际文件,这很好:

<div align="center">
<table width="630" border="0" cellspacing="1" cellpadding="0" style="background-color:white;">
<tr>
<td>
<table width="630" border="1" cellspacing="0" cellpadding="3">

当我查看页面源时,同样的事情:

<div align="center">
<table width="630" border="0" cellspacing="1" cellpadding="0" style="background-color:white;">
<tr>
<td>
<table width="630" border="1" cellspacing="0" cellpadding="3">

但是当我检查chrome上的元素时,它会显示以下内容:

<div align="center">
<table width="630" border="0" cellspacing="1" cellpadding="0" style="background-color:white;">
<tbody>
<tr>
<td>
<br>
<br>
<br>
<br>
<br>
<br>
<table width="630" border="1" cellspacing="0" cellpadding="3">

该表的完整代码如下:

<div align="center" class="tabContent" id="imminent">
<br>

<table width="630" border="0" cellspacing="1" cellpadding="0"  style="border-collapse:collapse" >
<tr>
<td>
<table width="630" border="0" cellspacing="0" cellpadding="3">


<br>
<div align="center">
<table width="630" border="0" cellspacing="1" cellpadding="0" style="background-color:white;">
<tr>
<td>
<table width="630" border="1" cellspacing="0" cellpadding="3">

<tr>
<td width="65" align="center"><label class="desc" id="title1" for="date">Date</label></font></td>
<td width="20" align="center"><label class="desc" id="title1" for="state">ST</label></font></td>
<td width="195" align="center"><label class="desc" id="title1" for="practice_name">Name</label></font></td>
<td width="70" align="center"><label class="desc" id="title1" for="status">Returned</label></font></td>
<td width="70" align="center"><label class="desc" id="title1" for="progress">Sent Info</label></font></td>
<td width="70" align="center"><label class="desc" id="title1" for="progress">F/U 2</label></font></td>
<td width="70" align="center"><label class="desc" id="title1" for="edit">F/U 3</label></font></td>
<td width="70" align="center"><label class="desc" id="title1" for="edit">F/U 4</label></font></td>
</tr>

<?php
while($rowsim=mysql_fetch_array($resultim)){


$var1im = '<abbr title="Completed on: '.$rowsim['sentdate'].'">'.$rowsim['sentinfo'].'</abbr>';
$var2im = '<abbr title="Completed on: '.$rowsim['follow2date'].'">'.$rowsim['follow2'].'</abbr>';
$var3im = '<abbr title="Completed on: '.$rowsim['follow3date'].'">'.$rowsim['follow3'].'</abbr>';
$var4im = '<abbr title="Completed on: '.$rowsim['follow4date'].'">'.$rowsim['follow4'].'</abbr>'; }

?>

<tr>
<td width="65">&nbsp;&nbsp;<? echo $rowsim['date']; ?></td>
<td width="20">&nbsp;<? echo $rowsim['state']; ?></td>
<td width="195">&nbsp;&nbsp;
<a href="webleads.php?id=<? echo $rowsim['id'];?>"> <? if($rowsim['name']!="") {echo $rowsim['name']; } else { echo $rowsim['office']; }?></a></td>
<td width="70">&nbsp;<? echo $rowsim['returned']; ?></td>
<td width="70">&nbsp;<? echo $var1im; ?></td>
<td width="70">&nbsp;<? echo $var2im; ?></td>
<td width="70">&nbsp;<? echo $var3im; ?></td>
<td width="70">&nbsp;<? echo $var4im; ?></td><br>
</tr>

<? } ?>

</table>

</td>
</tr>
</table>
<br />
</div>

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

我正在使用的Javascript代码是制作标签页。工作很长一段时间,直到发生这种情况。

<script type="text/javascript">
//<![CDATA[

var tabLinks = new Array();
var contentDivs = new Array();

function init() {

  // Grab the tab links and content divs from the page
  var tabListItems = document.getElementById('tabs').childNodes;
  for ( var i = 0; i < tabListItems.length; i++ ) {
    if ( tabListItems[i].nodeName == "LI" ) {
      var tabLink = getFirstChildWithTagName( tabListItems[i], 'A' );
      var id = getHash( tabLink.getAttribute('href') );
      tabLinks[id] = tabLink;
      contentDivs[id] = document.getElementById( id );
    }
  }

  // Assign onclick events to the tab links, and
  // highlight the first tab
  var i = 0;

  for ( var id in tabLinks ) {
    tabLinks[id].onclick = showTab;
    tabLinks[id].onfocus = function() { this.blur() };
    if ( i == 0 ) tabLinks[id].className = 'selected';
    i++;
  }

  // Hide all content divs except the first
  var i = 0;

  for ( var id in contentDivs ) {
    if ( i != 0 ) contentDivs[id].className = 'tabContent hide';
    i++;
  }
}

function showTab() {
  var selectedId = getHash( this.getAttribute('href') );

  // Highlight the selected tab, and dim all others.
  // Also show the selected content div, and hide all others.
  for ( var id in contentDivs ) {
    if ( id == selectedId ) {
      tabLinks[id].className = 'selected';
      contentDivs[id].className = 'tabContent';
    } else {
      tabLinks[id].className = '';
      contentDivs[id].className = 'tabContent hide';
    }
  }

  // Stop the browser following the link
  return false;
}

function getFirstChildWithTagName( element, tagName ) {
  for ( var i = 0; i < element.childNodes.length; i++ ) {
    if ( element.childNodes[i].nodeName == tagName ) return element.childNodes[i];
  }
}

function getHash( url ) {
  var hashPos = url.lastIndexOf ( '#' );
  return url.substring( hashPos + 1 );
}

//]]>
</script>

1 个答案:

答案 0 :(得分:0)

检查当前页面与页面源(显然)不同。每个浏览器都会解释所请求的代码。源显示浏览器收到的内容,检查显示解释。

Chrome(以及可能的其他浏览器)现在所做的一件事就是尝试通过提升标准来改进代码。您可能没有在页面中定义不同的(X)HTML文档类型,因此通过添加tbody来完成代码。解释还将(尝试)修复错误,例如拼写错误和缺少结束标记。

我无法重现换行符:您可以为此添加完整的代码吗?

更新:仍然无法重现换行符。它必须与PHP有关。您可能还想关闭外部两个表的trtd ...也许PHP不喜欢它。