function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dylan GerowDylan Gerow 

Automatically Resizing a Canvas App in Visualforce Page

I am implementing a canvas app into a visualforce page and would like for it to automatically resize based on whether someone is on mobile, different browser window size, etc. I checked the Canvas Developer's guide which says to use the autogrow feature for canvas apps you only need add the following code:

// Turn on auto grow with default settings.
Sfdc.canvas(function() {
sr = JSON.parse('<%=signedRequestJson%>');
Sfdc.canvas.client.autogrow(sr.client);
});

However, when I add this to my visualforce page, nothing happens, and the size of the visualforce page remains default. I have included my visualforce code below:

<apex:page controller="connectDataController" showHeader="false" sidebar="false" standardStylesheets="true" docType="html-5.0" language="en-US" applyHtmlTag="false">      
    
    <apex:canvasApp canvasId="mycanvas0" developerName="x" id="mycanvas0" scrolling="yes"/>
   
<script>
// Turn on auto grow with default settings.
Sfdc.canvas(function() {
sr = JSON.parse('<%=signedRequestJson%>');
Sfdc.canvas.client.autogrow(sr.client);
});
</script>
</apex:page>
Any ideas as to why this isn't working properly?

Thanks 

ghostdevghostdev
Hello,
have you tried to put the autogrow code into your canvas app ?

Also, try to put the maxHeight="infinite"  param to your canvas app tag,
in order to allow visual force page to grow beyond 2000px limit.
ghostdevghostdev
However, checkout here.
https://developer.salesforce.com/docs/atlas.en-us.platform_connect.meta/platform_connect/canvas_app_autogrow_code_example.htm?search_text=autogrow