how to adjust iframe height of an atlassian connect add on

Florian Bauer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 15, 2018

how can i resize my iframe to 100% height?

=> AP.resize('100%',100%') this does not work for the height value of course

i would like to have the iframe as big as possible, that there is no unused space and no scroll bars applied. therefore i need to know the height of my parent window. but this value is not accessible due to same origin policy.

  1. is there a way to obtain the parent window hight or
  2. is there a way to resize the parent window to maximum height: AP.resize(width, '100%')?

 

4 answers

1 accepted

0 votes
Answer accepted
Petter Gonçalves
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 18, 2020

Hello,

I just would like to give a quick update that we have the Atlassian Developer Community to properly address development questions:

https://community.developer.atlassian.com/ 

The mentioned portal was specifically created for development questions, where you will find articles and suggestions from third-party partners and Atlassian developers. Feel free to open a new topic about your question there! 

2 votes
henokMengistu November 2, 2018

Hey,

This method works for me.

First add ac-content attribute to the body tag:

<body class="ac-content">

Then in the script tag I added the following code, make sure that you have access to all.js

AP.resize('100%','100%');

AP.sizeToParent();

 

G H Mahimaanvita October 27, 2022

Thank you!

0 votes
Dugald Morrow
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 15, 2018

Hey @Florian Bauer

Thanks for your question. Would you mind providing a more concrete situation relating to your request. For example, I assume you're interested in doing this specifically in Jira, but which type of page and area within the page? Jira and Connect has the concept of a general page which you app can fill out.

See https://developer.atlassian.com/cloud/jira/platform/about-jira-modules/ 

Florian Bauer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 15, 2018

 

i just solved my problem. i was using the wrong web modul for jira. aparently the sizeToParent option is only available for general pages and also for jiraProjectPages (which is not yet part of the docs).

thank you guys for your help!!!

Dugald Morrow
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 15, 2018

Thanks @Florian Bauer, I've created https://ecosystem.atlassian.net/browse/ACJS-870 to improve the docs.

0 votes
Juan Manuel Ibarra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 15, 2018

Hi! Try to put this in de footer of your page

<script id="connect-loader" data-options="sizeToParent:true;">
(function() {
  var getUrlParam = function (param) {
    var codedParam = (new RegExp(param + '=([^&]*)')).exec(window.location.search)[1];
    return decodeURIComponent(codedParam);
  };

  var baseUrl = getUrlParam('xdm_e') + getUrlParam('cp');
  var options = document.getElementById('connect-loader').getAttribute('data-options');

  var script = document.createElement("script");
  script.src = baseUrl + '/atlassian-connect/all.js';

  if(options) {
    script.setAttribute('data-options', options);
  }

  document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>

For more information go to 

https://developer.atlassian.com/cloud/jira/platform/about-the-javascript-api/

Florian Bauer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 15, 2018

thank you juan for you quick response!

 

if i try this with sizeToParent:true option or even force it manually by AP.sizeToParent (true) the iframe size is 300x149.3333 only, which is pretty tiny ;)

this is how the iframe tag gets rendered:

<iframe id="add.on.name__board__34fef5c1" name="some json here" src="url" referrerpolicy="no-referrer" class="ap-iframe full-size-general-page-fail"></iframe>

 

i am wondering what this full-size-general-page-fail class means?

Suggest an answer

Log in or Sign up to answer