Newer Version Available
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.
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17//Subscribe to the parent window onscroll event.
18Sfdc.canvas(function() {
19 sr = JSON.parse('<%=signedRequestJson%>');
20 // Capture the onScrolling event of the parent window
21 Sfdc.canvas.client.subscribe(sr.client,
22 {name : 'canvas.scroll', onData : function (event) {
23 console.log("Parent's contentHeight; " + event.heights.contentHeight);
24 console.log("Parent's pageHeight; " + event.heights.pageHeight);
25 console.log("Parent's scrollTop; " + event.heights.scrollTop);
26 console.log("Parent's contentWidth; " + event.widths.contentWidth);
27 console.log("Parent's pageWidth; " + event.widths.pageWidth);
28 console.log("Parent's scrollLeft; " + event.widths.scrollLeft);
29 }}
30 );
31});