Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Subscribing to Parent Events
The following code example shows how to call the subscribe method so that a canvas app can subscribe to parent events. This example handles the onscroll event that fires when the user scrolls in the parent window.
1//Subscribe to the parent window onscroll event.
2Sfdc.canvas(function() {
3 sr = JSON.parse('<%=signedRequestJson%>');
4 // Capture the onScrolling event of the parent window
5 Sfdc.canvas.client.subscribe(sr.client,
6 {name : 'canvas.scroll', onData : function (event) {
7 console.log("Parent's contentHeight; " + event.heights.contentHeight);
8 console.log("Parent's pageHeight; " + event.heights.pageHeight);
9 console.log("Parent's scrollTop; " + event.heights.scrollTop);
10 console.log("Parent's contentWidth; " + event.widths.contentWidth);
11 console.log("Parent's pageWidth; " + event.widths.pageWidth);
12 console.log("Parent's scrollLeft; " + event.widths.scrollLeft);
13 }}
14 );
15});