The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to adjust width and height of iframe to fit with content in it in Confluence On-Demand

Xavier Arques
October 4, 2015

I'm developing a Dynamic content macro for Confluence Cloud that returns a dynamic HTML table.

Dynamic Content Macro documentation says "If the size of the macro output content size is dynamic, call AP.resize(w,h) immediately after the DOM of your iframe is loaded."

To retrieve width and height of the content, I found the following code on Internet:

var newheight = document.getElementById(id).contentWindow.document .body.scrollHeight; 
var newwidth = document.getElementById(id).contentWindow.document .body.scrollWidth;

But the frame id is generated dynamically and is not accessible through Context Parameter

So, how can I adjust i frame width and height to fit with content inside a dynamic content macro ?

Thanks

Xavier

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Robert Massaioli _Atlassian_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 4, 2015

I believe that the simplest method is to just use AP.resize() from inside your iFrame. Like so my Sketchfab for Connect addon does.

Xavier Arques
October 4, 2015

Robert, Thanks. It works fine if I don't declare parameter height in atlassian-connect.json. I will ask Atlassian to describe AP.resize() API behavior when there is no parameter (https://developer.atlassian.com/static/connect/docs/latest/javascript/module-AP.html)

Xavier Arques
October 5, 2015

Documention enhancement required through https://ecosystem.atlassian.net/browse/ACJS-71

Arek Åšliwa
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 23, 2017

AP.resize('100%', 'calc(100vh - 160px)');

TAGS
AUG Leaders

Atlassian Community Events