4 out of 6 rated this helpful - Rate this topic

uniqueID property

[This documentation is preliminary and is subject to change.]

Retrieves an autogenerated, unique identifier for the object.

Syntax

JavaScript

p = object.uniqueID

Property values

Type: String

String that specifies the unique identifier.

Remarks

When you apply this property to the document object, the client automatically generates a new ID that you can assign to an element's id property.

A new ID is generated and assigned to the element the first time the property is retrieved. Every subsequent access to the property on the same element returns the same ID.

Note  The unique ID generated is not guaranteed to be the same every time the document is loaded.

Examples

The following examples use the uniqueID property within an HTC to assign a unique identifier to an element.

This example assigns a uniqueID to an element from within a behavior. Every time the setTimeout method is invoked, the behavior-defined tick() function is called. The uniqueID attaches the element to the tick() function defined in the behavior's namespace.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/CustomTags/CustomFlying.htm


<PUBLIC:METHOD NAME="tick" />
<PUBLIC:METHOD NAME="startFly" />
<PUBLIC:PROPERTY NAME="from" />
<PUBLIC:PROPERTY NAME="fromX" />
<PUBLIC:PROPERTY NAME="fromY" />
<PUBLIC:PROPERTY NAME="delay" />
:
<SCRIPT LANGUAGE="jscript">
var currCount;
var flyCount;
var flying;
var msecs;
var oTop, oLeft;

msecs = 50;
flyCount = 20;
flying = false;

runtimeStyle.position = "relative";
runtimeStyle.visibility = "hidden";

window.attachEvent("onload", onload);

function onload()
{
  // delay commences from the window.onLoad event
  if (delay != "none")
  {
     window.setTimeout(uniqueID+".tick()", delay);
  }
}

function tick()
{
   if (flying == false)
   {
      startFly();
   }
   else
   {
      doFly();
   }
}
:
</SCRIPT>

This example uses the uniqueID property to show how the browser can autogenerate a unique ID for an element inserted into the document by a behavior.


<PUBLIC:ATTACH EVENT="onload" FOR="window" ONEVENT="init()" />
<SCRIPT LANGUAGE="JScript">

function init()
{
   // Specifying an ID=document.uniqueID ensures that a unique identifier
   // will be assigned to the element being inserted into the document by
   // the behavior.
   newTextAreaID = element.document.uniqueID;
   element.document.body.insertAdjacentHTML ("beforeEnd",
    "<P><TEXTAREA STYLE='height: 200 ;"+
    "width: 350' ID= " + newTextAreaID + "></TEXTAREA></P>");
}
</SCRIPT>

See also

a
abbr
acronym
address
applet
area
b
base
baseFont
bgSound
big
blockQuote
body
br
button
caption
center
cite
code
col
colGroup
comment
dd
del
dfn
dir
div
dl
document
dt
em
embed
fieldSet
font
form
frame
frameSet
head
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
link
listing
map
marquee
menu
noBR
object
ol
option
p
plainText
pre
q
s
samp
script
select
small
span
strike
strong
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
title
tr
tt
u
ul
var
xmp
Conceptual
Introduction to DHTML Behaviors
Using HTML Components to Implement DHTML Behaviors in Script

 

 

Build date: 3/8/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ