wjiamuw
小狐狸
小狐狸
  • UID9196
  • 注册日期2005-10-11
  • 最后登录2005-10-11
  • 发帖数1
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
阅读:4124回复:1

求教,关于HTMLtableElement。ie中可运行,ff不可以运行。

楼主#
更多 发布于:2005-10-11 16:26
如下代码中的javascript如果在ie中执行没问题,可是firefox执行总是不行。
item是一个HTMLtableElement,获取不到其中的element,更得不到值了。应该如何修改?

<script language="JavaScript">
function fnSelect() {
  var item = document.getElementById('itemRow');
  alert(item.all.name.innerText);
  alert(item.all.id.value);
}
</script>

<table id="itemRow">
  <tr><td><html:hidden name="abcForm" property="id"/>
  </td></tr>
  <tr><td><td id="code">CODE
  </td></tr>
</table>
chpn
小狐狸
小狐狸
  • UID10459
  • 注册日期2005-12-09
  • 最后登录2005-12-09
  • 发帖数6
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
1楼#
发布于:2005-10-11 16:26
在W3C标准当中没有 all , innerText
可以用item.rows[1].cells[1].innerText.replace(/<[^>]>/g,'"")
取得第2行第2列的innerText

下面是有关HTMLTableElement的参考,摘至《Javascript:The Definitive Guide》,4th Edition 即《Javascript权威指南》网上可以下载得到
       
HTMLTableElement a <table> in an HTML document

--------------------------------------------------------------------------------
  

Availability
DOM Level 1 HTML

Inherits from/Overrides
Node  Element  HTMLElement  HTMLTableElement

Properties
HTMLTableCaptionElement caption
A reference to the <caption> element for the table, or null if there is none.

readonly HTMLCollection rows
An array (HTMLCollection) of HTMLTableRowElement objects that represent all the rows in the table. This includes all rows defined within <thead>, <tfoot>, and <tbody> tags.

readonly HTMLCollection tBodies
An array (HTMLCollection) of HTMLTableSectionElement objects that represent all the <tbody> sections in this table.

HTMLTableSectionElement tFoot
The <tfoot> element of the table, or null if there is none.

HTMLTableSectionElement tHead
The <thead> element of the table, or null if there is none.

In addition to the properties just listed, this interface defines the properties in the following table to represent the HTML attributes of the <table> element.

Property
 Attribute
 Description
 
deprecated String align
 align
 Horizontal alignment of table in document
 
deprecated String bgColor
 bgcolor
 Table background color
 
String border
 border
 Width of border around table
 
String cellPadding
 cellpadding
 Space between cell contents and border
 
String cellSpacing
 cellspacing
 Space between cell borders
 
String frame
 frame
 Which table borders to draw
 
String rules
 rules
 Where to draw lines within the table
 
String summary
 summary
 Summary description of table
 
String width
 width
 Table width
 


Methods
createCaption( )
Returns the existing <caption> for the table, or creates (and inserts) a new one if none already exists.

createTFoot( )
Returns the existing <tfoot> element for the table, or creates (and inserts) a new one if none already exists.

createTHead( )
Returns the existing <thead> element for the table, or creates (and inserts) a new one if none already exists.

deleteCaption( )
Deletes the <caption> element from the table, if it has one.

deleteRow( )
Deletes the row at the specified position in the table.

deleteTFoot( )
Deletes the <tfoot> element from the table, if it has one.

deleteTHead( )
Deletes the <thead> element from the table, if one exists.

insertRow( )
Inserts a new, empty <tr> element into the table at the specified position.

Description
This interface represents an HTML <table> element and defines a number of convenience properties and methods for querying and modifying various sections of the table. These methods and properties make it easier to work with tables, but they could also be duplicated with core DOM methods.

See Also
HTMLTableCaptionElement, HTMLTableCellElement, HTMLTableColElement, HTMLTableRowElement, HTMLTableSectionElement
        


       
HTMLTableRowElement a <tr> element in an HTML table

--------------------------------------------------------------------------------
  

Availability
DOM Level 1 HTML

Inherits from/Overrides
Node  Element  HTMLElement  HTMLTableRowElement

Properties
readonly HTMLCollection cells
An array (HTMLCollection) of HTMLTableCellElement objects representing the cells in this row.

readonly long rowIndex
The position of this row in the table.

readonly long sectionRowIndex
The position of this row within its section (i.e., within its <thead>, <tbody>, or <tfoot> element).

In addition to the properties just listed, this interface also defines the properties in the following table, which correspond to the HTML attributes of the <tr> element.

Property
 Attribute
 Description
 
String align
 align
 Default horizontal alignment of cells in this row
 
deprecated String bgColor
 bgcolor
 Background color of this row
 
String ch
 char
 Alignment character for cells in this row
 
String chOff
 choff
 Alignment character offset for cells in this row
 
String vAlign
 valign
 Default vertical alignment for cells in this row
 


Methods
deleteCell( )
Deletes the specified cell from this row.

insertCell( )
Inserts an empty <td> element into this row at the specified position.

Description
This interface represents a row in an HTML table.
        


       
HTMLTableCellElement a <td> or <th> cell in an HTML table

--------------------------------------------------------------------------------
  

Availability
DOM Level 1 HTML

Inherits from/Overrides
Node  Element  HTMLElement  HTMLTableCellElement

Properties
readonly long cellIndex
The position of this cell within its row.

In addition to the cellIndex property, this interface defines the properties in the following table, which correspond directly to the HTML attributes of the <td> and <th> elements.

Property
 Attribute
 Description
 
String abbr
 abbr
 See HTML specification
 
String align
 align
 Horizontal alignment of cell
 
String axis
 axis
 See HTML specification
 
deprecated String bgColor
 bgcolor
 Background color of cell
 
String ch
 char
 Alignment character
 
String chOff
 choff
 Alignment character offset
 
long colSpan
 colspan
 Columns spanned by cell
 
String headers
 headers
 id values for headers for this cell
 
deprecated String height
 height
 Cell height in pixels
 
deprecated boolean noWrap
 nowrap
 Don't word-wrap cell
 
long rowSpan
 rowspan
 Rows spanned by cell
 
String scope
 scope
 Scope of this header cell
 
String vAlign
 valign
 Vertical alignment of cell
 
deprecated String width
 width
 Cell width in pixels
 


Description
This interface represents <td> and <th> elements in HTML tables.
        
游客

返回顶部