SP.NavigationNodeCollection.add(parameters) Method

SharePoint 2010

Last modified: June 30, 2010

Applies to: SharePoint Foundation 2010

Creates a navigation node object and adds it to the collection.

var value = SP.NavigationNodeCollection.add(parameters);


Describes the node to be created.

It must not be null.

Type: SP.NavigationNodeCreationInformation

The following example creates an input button on an application page that adds a node to the Quick Launch area of the current website and displays the current Quick Launch nodes.

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/ecmascript" language="ecmascript">

    var quickLaunchNodeCollection = null;
    var nnci = null;
    function runCode() {

        var clientContext = new SP.ClientContext.get_current();

        if (clientContext != undefined && clientContext != null) {
            var web = clientContext.get_web();

            // Get the Quick Launch navigation node collection.
            this.quickLaunchNodeCollection = web.get_navigation().get_quickLaunch();

            // Set properties for a new navigation node.
            this.nnci = new SP.NavigationNodeCreationInformation();
            // Create node as the last node in the collection.

            clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

    function onQuerySucceeded() {
        var nodeInfo = '';
        var nodeEnumerator = this.quickLaunchNodeCollection.getEnumerator();
        while (nodeEnumerator.moveNext()) {
            var node = nodeEnumerator.get_current();
            nodeInfo += node.get_title() + '\n';
        alert("Current nodes: \n\n" + nodeInfo);

    function onQueryFailed(sender, args) {
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());


    <input id="Button1" type="button" value="Run Code" onclick="runCode()" />