DOMStringList collection
Represents a collection of String objects.
The DOMStringList collection supports the common length property and the item method as other collections and an additional contains method.
With the contains method, you can search within the DOMStringList collection.
Syntax:
Properties that reference the object:
| dataTransfer.types |
Methods that return the object:
| dataTransfer.mozTypesAt (index) |
Possible members:
Properties:
Returns an integer that specifies the number of objects in the current collection.
This property is read-only. |
Methods:
[index] |
Returns an object from the current collection by index.
Parameters:
Return value:
Returns the String object at the specified position.
|
||||||||||||||||||
contains (strToSearch) |
Returns a Boolean value that indicates whether the specified string is a part of the current collection.
The search is case-sensitive and only whole words are matched.
Parameters:
Return value:
Boolean. One of the following values:
|
||||||||||||||||||
item (index) |
Returns an object from the current collection by index.
Parameters:
Return value:
Returns the String object at the specified position.
|
Example HTML code 1:
This example illustrates the use of the DOMStringList collection:
|
||||
<head> <script type="text/javascript"> function OnDropBody (event) { alert ("Please drop the item into the red field."); return false; } function OnDropTarget (event) { if (event.dataTransfer) { if (event.dataTransfer.types) { var infoTable = document.getElementById ("info"); var infoTableBody = infoTable.tBodies[0]; infoTableBody.innerHTML = ""; for (var i = 0; i < event.dataTransfer.types.length; i++) { var row = infoTableBody.insertRow (-1); var cell = row.insertCell (0); var type = event.dataTransfer.types[i]; cell.textContent = type; cell = row.insertCell (1); cell.textContent = event.dataTransfer.getData (type); } } else { alert ("Your browser does not support the types property."); } } else { alert ("Your browser does not support the dataTransfer property."); } if (event.stopPropagation) { event.stopPropagation (); } else { event.cancelBubble = true; } return false; } </script> </head> <body ondragenter="return false;" ondragover="return false;" ondrop="return OnDropBody (event);"> Please drag some text or a <a href="#">link</a> or a file (from outside this browser window) and drop it into the red field. If you drop more than one file, the table below the red field will only contain information about the first dropped file. <br /><br /> <div ondragenter="return false;" ondragover="return false;" ondrop="return OnDropTarget (event);" style="width:300px; height:100px; background-color:#f08080;"> </div> <br /><br /> The following table contains the available data formats and their corresponding values for the first dropped item. <table id="info" border="2px"> <thead> <tr> <th>Data type</th> <th>Data</th> </tr> </thead> <tbody> </tbody> </table> </body> |
||||
|
||||
Did you find this example helpful?
|
Related pages:
External links:
User Contributed Comments