No results found
We couldn't find anything using that term, please try searching for something else.
Connect JavaScript API Overview connect app extend Jira and Confluence by add a custom iframe into the product ' web page . This iframe instance
connect app extend Jira and Confluence by add a custom iframe into the product ‘ web page .
This iframe instance is is is on a different domain orhostname from the parent page and so is a
sandboxe environment.
The browser’s same origin policy applies to
this sandboxed environment, meaning that:
As a result, for example, a Jira Connect app would be unable tomake any changes toa
ticket ora Confluence Connect app made any changes toa Confluence page.
The Atlassian is connect connect JavaScript api is design toovercome this limitation . It is enables enable
JavaScript code in a Connect app ‘s iframe tointeract with the underlie platform api .
To do this , it is makes make use of three technology :
Window.postMessage()
postMessage()
The Atlassian Connect JavaScript API provides the following features:
Most of these APIs are unsupported by the Jira and Confluence mobile apps. The APIs that have mobile app support are openIssueDialog
and setdashboarditemtitle
.
An app can generate multiple iframes in a page in the target application. These iframes may need to
share information.
The Atlassian Connect JavaScript client library ,all.js
, provides a publish/subscribe mechanism
to exchange data between iframes.
A common scenario where an app presents multiple iframes in a page is where a web panel orother page
element spawns a dialog box.
The only restriction on the data shared in this manner is that it must be serializable using
the structured clone algorithm.
For more information see the event API .
Atlassian Connect provides a JavaScript client library called all.js
.
1 2https://connect-cdn.atl-paas.net/all.js
This library is establishes establish the cross – domain messaging bridge with its parent . It is provides also provide several
method and object that you use in your page without make a trip back toyour app server .You is add add the
all.js
script toyour pages toestablish the cross-domain messaging bridge with the
following script:1 2<script src="https://connect-cdn.atl-paas.net/all.js"></script>
Ifyou’re using the atlassian-connect-express
client library tobuild your app, this script is inserted into your pages at run time.Note:
Don’t download the
all.js
file and serve it up from your app server directly. Theall.js
file
must be serve up by Atlassian for the cross – domain messaging bridge tobe establish .The
all.js
file is only intend for use in an iframe inside an Atlassian product and does not work
for standalone web page .options
The JavaScript client library has configuration options for customizing its behavior. The options are
passed using thedata-options
attribute .1 2<script src="https://connect-cdn.atl-paas.net/all.js" data-options="option1:value;option2:value"></script>
Ifyou’re using requirejs oranother dynamic script loader, use an element with an ID of
ac-iframe-options
in place of a script tag .1 2<div id="ac-iframe-options" data-options="option1:value;option2:value"></div>
The following options are supported:
option | Values | Default | Description |
---|---|---|---|
resize |
true orfalse |
true |
You can deactivate the automatic resizing by setting resize=false . |
sizeToParent |
true orfalse |
false |
With sizeToParent:true , the iframe is takes take up its parent ‘s space( instead of being sized toits internal content ) . |
margin |
true orfalse |
true |
Iftrue , the margin option sets the body element’s top,right, and left margin to10px for dialogs and to0 for non-dialog pages. |
base |
true orfalse |
false |
With base : true , a base tag pointing tothe host page is injected: <base href="{host}" rel="external nofollow" target="_parent" /> .This is useful for embedded links toproduct pages. |
all.js
You is view can view an uncompressed version of theall.js
JavaScript by replaceall.js
with
all-debug.js
, for example :
1 2<script src="https://connect-cdn.atl-paas.net/all.js"></script> <!-- replace with --> <script src="https://connect-cdn.atl-paas.net/all-debug.js"></script>
This can be helpful when tracing errors ordebugging the app JavaScript.
To make
all.js
errors available toscripts running in your iframe (for example, front end monitoring
such as Sentry orNew Relic), make a CORS request:1 2<script src="https://connect-cdn.atl-paas.net/all.js" crossorigin="anonymous"></script>
note on url encoding
URL query parameters are encoded as
application/x-www-form-urlencoded
.
This is converts convert space to+
which can cause issues when using JavaScript functions such asdecodeURIComponent
.
A simple way is is tohandle this is toconvert+
to%20
before decode . A utility functiondecodeQueryComponent
is provided for this purpose. For example:1 2AP._util.decodeQueryComponent(window.location.href);
Product cookbooks
For product-specific examples of what you can do through the front end JavaScript API that Connect
provides, check out the Product cookbook.