Newer Version Available

This content describes an older version of this product. View Latest

Explicitly Resizing a Canvas App

The following code example shows how to call the resize method to resize a canvas app. If you don’t specify the height and width parameters, the parent window attempts to determine the height of the canvas app based on its content and then set the iFrame width and height accordingly.

1swfobject.registerObject("clippy.codeblock-0", "9");// Automatically determine the size.
2Sfdc.canvas(function() {
3    sr = JSON.parse('<%=signedRequestJson%>');
4    Sfdc.canvas.client.resize(sr.client);
5});
6
7// Set the height and width explicitly.
8Sfdc.canvas(function() {
9    sr = JSON.parse('<%=signedRequestJson%>');
10    Sfdc.canvas.client.resize(sr.client, {height : "1000px", width : "900px"});
11});
12
13// Set only the height.
14Sfdc.canvas(function() {
15    sr = JSON.parse('<%=signedRequestJson%>');
16    Sfdc.canvas.client.resize(sr.client, {height : "1000px"});
17});
18