我无法在当前窗口中显示包含88个单元格的html表 [英] I can't get a html table with 88 cells to display in current window

查看:133
本文介绍了我无法在当前窗口中显示包含88个单元格的html表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用两个框架的顶部和主要框架.我使用aspx文件显示具有88个可单击单元格的html表.当用户单击该单元格时,该单元格应该将信息发送到另一个js函数,该函数将适当的报告显示到主框架,但该表显示在顶部框架而不是主框架中.我添加了parent.main.location.document.write(");表代码,它确实显示在主窗口中,但随后单元格不会单击,因此无法使用.我该怎么办?
*****这是表格代码****

I am using frames with top and main for the two frames. I use aspx files to display a html table with 88 clickable cells. When the user clicks on the cell, the cell is supposed to send the information to another js function which displays the appropriate report to the main frame but the table appears in the top frame and not the main. I added parent.main.location.document.write(""); for the table code and it did display in the main window but then the cells wouldn''t click so it was not usable. What can I do?
*****This is the Table code****

<script type="text/javascript">

function CreateTable(){
	document.write("<table align=''center'' id=''tblMain'' border=''1'' >"); 
    for (var i = 0;i<= 87;i++){
        if (i % 7 == 0){document.write ("<tr>");}
        document.write("<td><a HREF=''java<!-- no -->script:DisplayConstellations(" + i + ");''>" + ConName[i] + "</a></td>");                          
        if (i % 7 == 7){document.write ("</tr>"); }
    }
            document.write ("</table>");
}

推荐答案

不是完整的解决方案,但是您的代码中有错误:
Not a complete solution, but there are errors in your code:
var needfooter;	


该变量未初始化(好吧,这是因为您的循环总是在i == 87处结束).但是在那种情况下,剩余的逻辑有些瑕疵.


The variable is not initialized (well it will be because your loop always ends at i == 87). But in that case, the remaining logic is somewhat flawed.

if (i % 8 == 8){ ... }


该条件永远不会为真,因为%将返回0到7之间的一个值(包括0和7).

因此,最终,您不一定总能获得预期的输出.

顺便说一句,您的病情也很严重.如果最后一个i是87,则它是该行中的最后一个单元格,在这种情况下您不需要页脚.

因此,您得到的表具有不匹配的

.无效的HTML代码可能并不总是在所有浏览器上都显示您想要的内容.

在您喜欢的浏览器中,显示源代码并进行验证并相应地修复代码.

顺便说一句,最好为此编写单元测试代码,并验证您是否获得了任意大小的预期输出.你应该测试边缘情况...

更新

如果您的问题与内容的显示位置有关,则从问题中删除无关的内容(请参见下面的评论).

顺便说一句,如果您在iframe中,则所有JavaScript代码都将与该iframe相关.据我所知,您无法从代码访问外部框架.您唯一可以做的就是在顶部窗口中打开一个链接.仍然您的示例代码并未显示您拥有iframe.


That condition will never be true since % will returns a value between 0 and 7 inclusively.

Thus in the end, you don''t always get the expected output.

By the way, your condition are also broken. If the last i is 87, then it is that last cell in that row and you don''t need the footer in that case.

Thus you get a table with unmatched and

. Invalid HTML code might not always display what you want on all browsers.

In your prefered browser, display source code and verify it and fix code accordingly.

By the way, it would be a good idea to write unit test code for that and validate that you get the intended output for any size. You should test edge cases...

Update

If your problem is about where the content is displayed, then remove unrelated stuff from your question (see comment below).

By the way, if you are in a iframe, then all JavaScript code will relate to that iframe. As far as I know, you cannot access the outer frame from code. The only thing you could do is to open a link in top windows. Still your sample code do not show that you have an iframe.


这篇关于我无法在当前窗口中显示包含88个单元格的html表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆