Documentation

Navigator

The Navigator API allows your add-on to change the current page 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:
Name Type Description
callback function

function (location) {...}

Example
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:
Name Type Description
target Navigator~target~JIRA | Navigator~target~Confluence

The type of page to navigate to.

context Navigator~context

Specific information that identifies the page to navigate to.

Example
// 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'
});

reload()

Triggers a reload of the parent page.

Example
AP.navigator.reload();