extra html that I did not write

冷暖自知 提交于 2019-12-11 08:35:34

问题


My program has a bug -- the output has extra junk in it that doesn't belong there. Firebug shows me lines of code that would produce exactly this unwanted junk, but I don't have those lines in my program. I have spent hours on this and cannot solve it. Here is what Firebug says I have (the stuff in wavy brackets are my comments:

<tr>
<td class="repnum" style="width: 20px">1 </td>                {td 1}
<td class="reprow" style="text-align: left; "> Maura</td>     {td 2}
<td class="reprow" style="text-align: left; "> Cronin</td>    {td 3}
<td class="repsort subhead"> </td>                   cannot find this anywhere 
</tr>
<tr>                                                 cannot find this anywhere
<td class="repsort2 subhead "> </td>                 cannot find this anywhere
</tr>                                                cannot find this anywhere

Part of my program below. The actual program has other ColdFusion stuff in it, but no additional HTML.

 <tr>
   ... other stuff ...
 <cfloop from = "#subpage1#" to = "#subhind_1#" index = "j"> 
 <cfif sortnum[j] EQ 'y'>
   <cfif subhdup[j][row] EQ "NO">
   <cfset ctr[j] = 1>
   <cfelseif subhdup[j][row] EQ "YES">
   <cfset ctr[j] = ctr[j] + 1> <cfloop from = "#subpage1#" to = "#subhind_1#" index = "j"> 
   <cfif sortnum[j] EQ 'y'>
   <cfif subhdup[j][row] EQ "NO">
   <cfset ctr[j] = 1>
   <cfelseif subhdup[j][row] EQ "YES">
   <cfset ctr[j] = ctr[j] + 1>
   </cfif>

   <td class = "repnum" style = "width: 20px">#ctr[j]# </td>  td 1
 </cfif>
 </cfloop>


<cfloop from = "#subhind#" to = "#bbcollen#" index = "j">
<cfset col = bbcol[j]>

 <cfset i = i + 1>
       <cfif linefold GT 0>
       <cfset imod = i%linefold>
       <cfelse>
       <cfset imod = 1>
       </cfif>

       <cfif linefold EQ 0 OR (linefold GT 0 AND i LE linefold)> 
       <cfset lineclass = "reprow">
       <cfelse>
       <cfset lineclass = "reprow2">
       </cfif> 

      <cfif repdetail NEQ 'n'>     
      <cfoutput>
      <cfset jcol = inpcol[j]>
      <cfset temp    = structaux["#jcol#InputType"]> 

      <cfif temp EQ "num" OR temp EQ "one"> 
        <cfset anumform = NumberFormat(qrep[col][currentrow],.99)>
           <td class = "#lineclass#" style = "text-align: right"> #anumform#</td> 
      <cfelseif temp EQ "date">
           <cfset adate = DateFormat(qrep[col][currentrow],'mm/dd/yyyy')>
              <cfif adate EQ "01/01/1001">
              <cfset adate = "~">
              </cfif>
           <td class = "#lineclass#" style = "text-align: left"> #adate#</td> 
      <cfelse>
            <td class = "#lineclass#" style = "text-align: left; "> #qrep[col][row]#</td>

      </cfif><!---temp eq num --->

</cfloop> <!---subhind to bbcollen --->  
  ... other stuff ...
</tr>

Does anyone have a suggestion?


as per request I had expanded the code presented

Someone said that this is about whitespace. It is not. If it were whitespace I'd be okay. But I've got all sorts of css dropping into those extra spaces, creating borders etc. It really produces an illegible mess.


回答1:


I think this Stack question can better answer why there is random html output. It could also be the browser trying to correct all of the incorrect HTML that is possibly in your code.. in other words, you might have a small error such as your tags are not matched together.. either way, the browser is catching the errors and still producing the exact code that you want. With that being said, it really isn't anything to fret over unless you want to overlook your code and find exactly where the tags may not be matching up.

As I have extremely limited knowledge on ColdFusion, I would suggest a Syntax Checker that another Stack question has gone over. After finding if your syntax is correct or not, this may highlight the exact area that needs to be worked on.




回答2:


ColdFusion will not generate <tr> or <td> unless the code says so.

Normally extra white space is not significant and will not alter what is shown on the browser.

If you do have a region that must not have space, add it <cfsilent> make to remove space generation.




回答3:


Make sure you are really looking at the correct block of code. The reason I say that is because your CF logic has spaces on either side of the equal sign for the class attribute but the rendered HTML doesn't (I'm not sure if you modified it or not). I use CF daily and have never seen this. When viewing source the browser will add html from time to time like <thead> and <tbody> tags but nothing like in your example. I'd say (1) make sure you are looking at the correct block of code (2) show more of your page so we can follow the process, for instance, what is setting #lineclass#. Just follow the logic, add some cfdumps, or post the full page so we can help more.




回答4:


I would be willing to bet your a 1974 Ford Pinto that if you do an extended text search on all of the code in your project, all of the file types, you will find the code that you're considering extra.



来源:https://stackoverflow.com/questions/20794298/extra-html-that-i-did-not-write

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!