namespaces property

Retrieves a collection of namespace objects.



p = object.namespaces

Property values

Type: IDispatch

Array of namespace objects.

Standards information

There are no standards that apply here.


This sample demonstrates how to programmatically retrieve the names for all namespaces within the primary document.

Code example:

<html xmlns:firstNS
<?import namespace="firstNS" implementation="">
<?import namespace="secondNS" implementation="">
<?import namespace="thirdNS" implementation="">
<script type="text/javascript">
function getNS(){
    // Retrieving the namespace's name two different ways.
    var strInfo = "The following methods demonstrate how to retrieve a "
    strInfo += "namespace's name.\n\n";
    for(x = 0; x < document.namespaces.length; x++){
        oRow = oTable.insertRow();
        //Create cell with the Index.
        oCell = oRow.insertCell();
        oCell.align = 'center';
        oCell.innerText = x;
        /* Create cell with the namespace name using
            document.namespaces.item(iIndex).name. */
        oCell = oRow.insertCell();
        oCell.align = 'center';
        oCell.innerText = document.namespaces.item(x).name;
        /* Create cell with the namespace name using
            document.namespaces(iIndex).name. */
        oCell = oRow.insertCell();
        oCell.align = 'center';
        oCell.innerText = document.namespaces(x).name;
<table id="oTable" border=1>
<button id="btn1" onclick="getNS();">Retrieve names</button>

See also


Introduction to Viewlink

About Element Behaviors