2010-12-09 102 views
-2

当我点击IE上的行时,它会调用hello()方法并且工作正常,但不能在Firefox中使用。我怀疑这条线为什么这不起作用在Firefox中,但在IE中正常工作

tr align="left" bgcolor="eeeeee" style="padding-top: 3px; cursor: pointer;"> 

,因为当我删除它,它的工作原理有点

<script language="javascript" type="text/javascript"> 
    function hello(){ 
    alert('hello'); 
    } 
</script> 
<span style="" onclick="hello();" 
    onmouseover="this.children[0].style.backgroundColor='#D8EEEE'; this.children[1].style.backgroundColor='#D8EEEE';" 
    onmouseout="this.children[0].style.backgroundColor=''; this.children[1].style.backgroundColor='';"> 
<tr align="left" bgcolor="eeeeee"> 
    style="padding-top: 3px; cursor: pointer;"> 
    <td class="blueFont" style="font-weight: bold; <%=style%>"> 

我试图从已经的onclick

+1

请告诉什么不起作用,并显示您在Firefox中遇到的错误。此外,你应该显示呈现的最终HTML代码,而不是ASP源 – 2010-12-09 12:17:42

+0

我重新格式化你的代码。我说的是“某种”,因为那里肯定缺少一些东西。有一种风格从无处出现,例如... – nico 2010-12-09 12:24:45

回答

3

HTML无效,<span>元素不能包含<tr>元素。 Firefox和Internet Explorer正尝试以不同的方式从中恢复。

IIRC,Internet Explorer将包裹<tr><span>反正,而Firefox将移动<span>所以它是<table>结束后。因此,您尝试访问的跨度的子元素不存在。

开始于valid HTML。您可以使用<thead><tfoot><tbody>元素标记表格的各个部分。

2

去除分号因为你已经有了一个' tr'在'span'内?

相关问题