Created
May 15, 2017 19:54
-
-
Save cookieseller/9b539a855a6137ccdc1f056d0ba313ec to your computer and use it in GitHub Desktop.
IFrame Resize XPages
This file contains hidden or 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
| window.addEventListener( "message", | |
| function (event) { | |
| console.log('Received event: ', event.data); | |
| var xpageiFrame = document.getElementById("groupsWidget"); | |
| xpageiFrame.style.height = event.data; | |
| }, false); | |
| <xp:scriptBlock type="text/javascript"> | |
| <xp:this.value> | |
| <![CDATA[ | |
| var sendEvent = function() { | |
| var height = document.body.scrollHeight; | |
| parent.postMessage(height + "px", "*"); | |
| }; | |
| window.onresize = function() { | |
| sendEvent(); | |
| }; | |
| ]]> | |
| </xp:this.value> | |
| </xp:scriptBlock> | |
| <xp:eventHandler event="onClientLoad" submit="true" | |
| refreshMode="norefresh"> | |
| <xp:this.script> | |
| <![CDATA[ | |
| sendEvent(); | |
| setTimeout(sendEvent, 500); | |
| ]]> | |
| </xp:this.script> | |
| </xp:eventHandler> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment