Newer Version Available

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

Getting the Size of a Canvas App

The following code example shows how to call the size method to get the size of the canvas app. The console.log function outputs the frame sizes so you can see the sizes change as you resize the canvas app.

1swfobject.registerObject("clippy.codeblock-0", "9");// Get the canvas app sizes in the sizes object.
2var sizes = Sfdc.canvas.client.size();
3
4console.log("contentHeight; " + sizes.heights.contentHeight);
5console.log("pageHeight; " + sizes.heights.pageHeight);
6console.log("scrollTop; " + sizes.heights.scrollTop);
7console.log("contentWidth; " + sizes.widths.contentWidth);
8console.log("pageWidth; " + sizes.widths.pageWidth);
9console.log("scrollLeft; " + sizes.widths.scrollLeft);
10
11// Resize the canvas app.
12Sfdc.canvas(function() {
13    sr = JSON.parse('<%=signedRequestJson%>');
14    Sfdc.canvas.client.autogrow(sr.client);
15});