sourceIndex property

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
4 out of 5 rated this helpful - Rate this topic

Retrieves the ordinal position of the object, in source order, as the object appears in the document's all collection.

Syntax

JavaScript

p = object.sourceIndex

Property values

Type: Integer

the ordinal position.

Examples

This example uses the sourceIndex property to identify the previous and next elements in the all collection.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/sourceIndex.htm


<script type="text/javascript">
function fnHandler(){
   // Retrieve the element that fired the event.
   var oElement=event.srcElement;
   var iIndex=oElement.sourceIndex;
   var sTagName=oElement.tagName;
   if(sTagName=="!"){
      sTagName="comment";
   }
   oVal1.innerText=iIndex;
   oVal2.innerText=sTagName;
   if(iIndex-1>0){
      sTagName=document.all[iIndex-1].tagName;
      if(sTagName=="!"){
         sTagName="comment";
      }   
      oVal3.innerText=sTagName;
   }
   else{
      oVal3.innerText="Cannot read.";
   }
   if(iIndex+1<document.all.length){
      sTagName=document.all[iIndex+1].tagName;
      if(sTagName=="!"){
         sTagName="comment";
      }   
      oVal4.innerText=sTagName;
   }
   else{
      oVal4.innerText="Cannot read.";
   }
}
</script>
<body onmousemove="fnHandler()">

<table>
  <tr>
	<td>Source Index:</td>
	<td id="oVal1"></td>
  </tr>
  <tr>
	<td>Object Name:</td>
	<td id="oVal2"></td>
  </tr>
  <tr>
	<td>Previous Object:</td>
	<td id="oVal3"></td>
  </tr>
  <tr>
	<td>Next Object:</td>
	<td id="oVal4"></td>
  </tr>
</table>

</body>


See also

a
abbr
acronym
address
applet
area
article
aside
b
bdo
big
blockQuote
body
br
button
caption
center
cite
code
col
colGroup
custom
dd
del
dfn
dir
div
dl
dt
em
embed
fieldSet
figcaption
figure
font
footer
form
frame
frameSet
head
header
hgroup
hn
hr
html
i
iframe
img
input type=button
input type=checkbox
input type=file
input type=hidden
input type=image
input type=password
input type=radio
input type=reset
input type=submit
input type=text
ins
isIndex
kbd
label
legend
li
listing
map
mark
marquee
menu
nav
nextID
noBR
object
ol
optGroup
option
p
plainText
pre
q
rt
ruby
s
samp
section
select
small
span
strike
strong
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
tr
tt
u
ul
var
xmp

 

 

Send comments about this topic to Microsoft

Build date: 11/28/2012

Did you find this helpful?
(1500 characters remaining)

Community Additions

© 2013 Microsoft. All rights reserved.