Skip to content

Commit

Permalink
Add docs for google apps script
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjbradshaw committed Feb 12, 2024
1 parent a6f419a commit 3e4c8e1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ IFrame-Resizer provides an extensive range of options and APIs for both the pare
- [Angular](https://github.com/davidjbradshaw/iframe-resizer/issues/478#issuecomment-347958630)
- [Ember](https://github.com/alexlafroscia/ember-iframe-resizer-modifier)
- [jQuery](https://github.com/davidjbradshaw/iframe-resizer/blob/master/docs/use_with/jquery.md)
- [Google Apps Script](https://stackoverflow.com/a/65724113/2087070)
- [Google Apps Script](https://github.com/davidjbradshaw/iframe-resizer/blob/master/docs/use_with/google_apps_script.md)
- [Troubleshooting](https://github.com/davidjbradshaw/iframe-resizer/blob/master/docs/troubleshooting.md)
- [Upgrade from version 3](https://github.com/davidjbradshaw/iframe-resizer/blob/master/docs/upgrade.md)
- [Version history](https://github.com/davidjbradshaw/iframe-resizer/blob/master/CHANGELOG.md)
Expand Down
2 changes: 2 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
- [React](https://github.com/davidjbradshaw/iframe-resizer-react)
- [Vue](https://github.com/davidjbradshaw/iframe-resizer/blob/master/docs/use_with/vue.md)
- [Angular](https://github.com/davidjbradshaw/iframe-resizer/issues/478#issuecomment-347958630)
- [Ember](https://github.com/alexlafroscia/ember-iframe-resizer-modifier)
- [jQuery](use_with/jquery.md)
- [Google Apps Script](use_with/google_apps_script.md)
- [Troubleshooting](troubleshooting.md)
- [Upgrade from version 3](upgrade.md)
- [Version history](../CHANGELOG.md)
32 changes: 32 additions & 0 deletions docs/use_with/google_apps_script.md
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.

0 comments on commit 3e4c8e1

Please sign in to comment.