This page is In Progress

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

lookupPrefix

Summary

Gets the namespace prefix associated with a URI, if any.

Method of dom/Nodedom/Node

Syntax

var prefix = node.lookupPrefix(/* see parameter list */);

Parameters

namespaceURI

Data-type
String

The namespace URI.

Return Value

Returns an object of type StringString

The namespace prefix associated with the URI, or null if none is found.

Examples

<html xmlns="http://www.w3.org/1999/xhtml"  xmlns:svg="http://www.w3.org/2000/svg">
   <script type="text/javascript">//<![CDATA[
    var nsxml = 'http://www.w3.org/1999/xhtml';
    var nssvg = 'http://www.w3.org/2000/svg';
    alert('root element nsprefix is ' + document.documentElement.lookupPrefix(nssvg));
   //]]></script>

Related specifications

DOM Level 3 Core
Recommendation

Attributions