Created
August 4, 2016 13:31
-
-
Save diogoca/44499093668b03813e7d0b5c1d91edae to your computer and use it in GitHub Desktop.
Auto iframe resize sem problema de CORS
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) { | |
| var iframe = document.getElementById(event.data.id) | |
| var newHeight = event.data.height; | |
| if (iframe) { | |
| iframe.height = parseInt(newHeight) + "px"; | |
| console.log("Iframe resized"); | |
| } else { | |
| console.error("Not found element id for #" + event.data.id); | |
| } | |
| }); | |
| // Chamando dentro do iframe | |
| parent.postMessage({ id: "jobboard_iframe", height: 200 }, "*"); | |
| // Ids disponiveis | |
| jobboard_iframe | |
| applynow_iframe | |
| login_iframe | |
| <script type="text/javascript"> | |
| window.onload = function() { | |
| var $ = jQuery; | |
| var iframe = '<iframe id="jobboard_iframe" name="jobboard_iframe" src="https://secure.laboredge.com/le-orp/account/jobBoardView.do?t=2a139a55" width="100%" height="715" frameborder="0"></iframe>'; | |
| $('section').append(iframe); | |
| } | |
| </script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment