-
-
Notifications
You must be signed in to change notification settings - Fork 983
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6f419a
commit 3e4c8e1
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
## Google Apps Script | ||
|
||
The [Google Apps Script](https://www.google.com/script/start/) platform creates a nested iframe between your app and the page it is host on. This creates a unique challenge for **iframe-resizer**, as it needs to be able to talk with the iframe it is using to calculate the page size from. | ||
|
||
This can be overcome by providing **iframe-resizer** some hints on where it needs send messages to communicate between the parent page and the iframe. | ||
|
||
### iframe | ||
|
||
The first step is to add the following line of code into your GAS application. This will send a message to the parent page, that we can then pass the detials of to **iframe-resizer**. | ||
|
||
```html | ||
top.postMessage('gasFrame', '*') | ||
``` | ||
|
||
### Parent Page | ||
|
||
The parent page needs to wait to recieve the above message before starting **iframe-resize** and then pass it the recieved referrences to the application iframe. | ||
|
||
```js | ||
window.addEventListener("message", (event) => { | ||
if (event.data === 'gasFrame') { | ||
iframeResize({ | ||
log: true, | ||
checkOrigin: event.origin, | ||
offsetHeight: 20, | ||
postMessageTarget: event.source | ||
}, '#myGasIframe') | ||
} | ||
}, false) | ||
``` | ||
|
||
The value for `offsetHeight` may need to be adjusted based on the content of your iframe. |