Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
Francis_Kabinoff
Former Employee
Former Employee

If you're familiar with iframes, you're probably familiar with the fact that they don't handle dynamic height very well. In other words, when you use an iframe you have to define it's height, and it does not change based on the height of it's content.

 

This can be problematic. For instance, if I use the single configurator to embed a large pie chart, and define the iframe's height so that the entire pie chart is displayed without scrolling, if the pie chart shrinks in height on a smaller device it will leave extra empty space in the iframe. Another common time I run into this problem is when embedding mashups that are responsive with content that wraps on mobile, or with multiple views that have different heights.

 

You may run into this problem, too, when using the single configurator or embedding mashups, as I often do. What can you do about it?

 

Using Pym.js

Pym.js is a super useful library when dealing with iframes. With pym.js, your iframes will respond to the height of their content, making their integration into your page much more seamless by avoiding either extra empty space or inner-page scrollbars, and it's pretty easy to use, too!

 

So how do you actually use it?

 

Well, first thing to know is that pym.js must be placed on both the child site and the parent site, so if you'd like to use this with an object from the single configurator, for instance, you'll have to put together a quick mashup. Super simple. Let's do that as an example, and then you should be able to apply the same idea to any situation you'd like to use pym.js.

 

Step 1 - Add necessary code to your mashup

Require pym.js, and include var pymChild = new pym.Child()

require( ["js/qlik", "https://pym.nprapps.org/pym.v1.min.js"], function ( qlik, pym ) {

  var pymChild = new pym.Child();

 

//rest of your code...

 

Step 2 - Override html and body height 100%

Qlik Sense mashups set html and body height to 100%, this will not work with pym.js. Just add the following css

html, body {

  height: auto !important;

}

 

That's all that needs to be done in the mashup.

 

Step 3 - Embed mashup in website with pym.js

Include the following in your website to embed the mashup with pym.js

<!-- This adds pym.js to your page -->

<script src="https://pym.nprapps.org/pym.v1.min.js"></script>

 

<!-- This is the container for the frame -->

<div id="example"></div>

 

<!-- This is the pym.js method that adds the frame to the page. -->

<!-- Make sure the first param matches the container id, and the second param is the url to the mashup -->

<script>

  var pymParent = new pym.Parent('example', 'example.html', {});

</script>

 

And that's it.

 

I've put up an example to show you the difference between using pym.js and not. This page https://demos.qlik.com/extensions/pym-example/iframe.html includes a large pie chart that is set to have it's width equal its height, and its width equal to 30% of the page, and is simply iframed in to fit nicely at full screen, but make the screen smaller and notice all the empty space between the pie chart and the "Some other content" string that sits outside of the iframe.

 

This page https://demos.qlik.com/extensions/pym-example/pym.html uses pym.js, and when you resize, the iframe height also adjusts, so that it's not taking up a bunch of unnecessary space.

15 Comments
IAMDV
Luminary Alumni
Luminary Alumni

Thanks, this will be a useful tip.

2,545 Views
vadimtsushko
Partner - Creator III
Partner - Creator III

Hi, Francis.

I'm trying to look at examples, but they are requiring authorisation so no luck.

Standard qliksense demo hub works without athorisation though.

2,545 Views
Francis_Kabinoff
Former Employee
Former Employee

Hey Vadim,

Thanks for pointing that out. Fixed.

0 Likes
2,545 Views
santiago_respane
Specialist
Specialist

Thanks for sharing!

Very interesting post.

Regards,

0 Likes
2,545 Views
IAMDV
Luminary Alumni
Luminary Alumni

Francis - Still asking for the password. Am I missing something?

2,545 Views
Francis_Kabinoff
Former Employee
Former Employee

Hey Deepak,

You're not missing anything, I'm just a goof. I changed the name of the hyperlink, but not the actual url in my haste earlier. Should be fixed now.

2,545 Views
jptneumann
Partner Ambassador
Partner Ambassador

Thanks for Sharing Francis. Great tip!

0 Likes
2,189 Views
rbartley
Specialist II
Specialist II

Hi Francis,

The url to your examples doesn't seem to work.  It diverts to https://demos.qlik.com/qliksense .

I'm really interested in trying this out, so any help you can give would be much appreciated.

Regards,

 

Richard

0 Likes
1,956 Views
rbartley
Specialist II
Specialist II

..also, I notice that when using the single API to embed a whole sheet, this view is not completely responsive (see below), so when I use this as the source of the iframe, the responsiveness breaks down at phone size and the same happens when using pym.

Unresponsive iframe.PNG

0 Likes
1,952 Views
didierodayo
Partner - Creator III
Partner - Creator III

@Francis_Kabinoff 

 

Hi Francis. this is great. do you have similar steps for Qlik enterprise SaaS Sheet integration into Salesforce? I found that the height adjustment is a problem depending on the screen being used.

Thanks 

1,075 Views