sourceIndex property

all
alt
ch
dir
id
min
rel
top
url
URL
urn
Expand Minimize
1 out of 1 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.


<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
address
area
article
aside
b
bdo
blockQuote
body
br
button
caption
cite
code
col
colGroup
custom
dd
del
div
dl
dt
em
embed
fieldSet
figcaption
figure
footer
form
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
kbd
label
legend
li
map
mark
nav
object
ol
optGroup
option
p
pre
q
rt
ruby
s
samp
section
select
small
span
strong
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
tr
u
ul
var

 

 

Build date: 11/28/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.