Navigator

On This Page

    The Navigator API enables your add-on to change the page displayed using JavaScript.

    Methods

    getLocation (callback)

    Returns the context of the current page within the host application.

    This method will provide a context object to the passed in callback. This context object will contain information about the page currently open in the host application.

    The object will contain a target, which can be used when calling the go method, and a context map containing in formation about the opened page.

    Currently this method supports two contexts in Confluence only:

    contentview - The host application is currently viewing a page, blog post or other content.

    contentedit - the host application is currently editing a page, blog post or other content.

    Parameters

    NameTypeDescription
    callback

    function

    function (location) {...}

    Example

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    AP.navigator.getLocation(function (location) {
      console.log(location)
      // location will be:
      // {
      //   "target": "contentview",
      //   "context": {
      //     "contentId": 1234,
      //     "contentType": "page",
      //     "spaceKey": "DS"
      //   }
      // }
    });

    go (target, context)

    Navigates the user from the current page to the specified page. This call navigates the host product, not the iframe content.

    Requires a target location and the corresponding context. Navigating by passing a concrete url is currently unsupported.

    Parameters

    NameTypeDescription
    targetNavigator~target~Jira || Navigator~target~Confluence

    The type of page to navigate to.

    contextNavigator~context

    Specific information that identifies the page to navigate to.

    Example

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    // To navigate to the view page for a piece of content in Confluence:
    AP.navigator.go('contentview', {contentId: '12345'});
    
    // To navigate to the view page for version 2 of a piece of content in Confluence:
    AP.navigator.go('contentview', {contentId: '12345', versionOverride: 2});
    
    // To navigate to the edit page for a piece of content in Confluence:
    AP.navigator.go('contentedit', {contentId: '12345'});
    
    // To navigate to the issue view page of an issue in Jira:
    AP.navigator.go('issue', {
      issueKey: 'TEST-1'
    });
    
    // To navigate to any page in the current site:
    AP.navigator.go('site', {
      relativeUrl: '/browse/TEST-1'
    });

    reload()

    Triggers a reload of the parent page.

    Throttle is applied to prevent infinite reloads

    Example

    1
    AP.navigator.reload();

    Rate this page: