Microsoft KB Archive/264470

= How To Access Table Cells Using x and y Coordinates Through DHTML =

Article ID: 264470

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer (Programming) 5.01 SP1
 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q264470



SUMMARY
The following sample uses the elementFromPoint method to return the cell element's specific x and y coordinates. The sample then uses the cellIndex and rowIndex properties to retrieve the cell's position in the cells collection and rows collection, respectively.



MORE INFORMATION
  

function getCellInfo(oObject) {   if ( oObject == null ) return;

var objCell = document.elementFromPoint( window.event.x, window.event.y );

if ( objCell.tagName != &quot;TD&quot; ) return;

intCellIndex = objCell.cellIndex; intRowIndex = objCell.parentElement.rowIndex;

text1.value = intRowIndex + &quot;, &quot; + intCellIndex; text2.value = objCell.innerHTML; }  

  Current row and column:   Current text:   

