all
alt
ch
dir
id
min
rel
top
url
URL
urn
Expand Minimize

sourceIndex property

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
dfn
div
dl
dt
em
embed
fieldSet
figcaption
figure
footer
form
frame
head
header
hgroup
hn
hr
html
i
iframe
img
input type=button
input type=checkbox
input type=email
input type=file
input type=hidden
input type=image
input type=number
input type=password
input type=radio
input type=range
input type=reset
input type=search
input type=submit
input type=tel
input type=text
input type=url
ins
kbd
label
legend
li
map
mark
menu
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

 

 

Show:
© 2014 Microsoft. All rights reserved.