![]() If ( (typeof e.data = 'string') & (e.data. Check that message being passed is the documentHeight Var messageEvent = eventMethod = "attachEvent" ? "onmessage" : "message" ![]() Var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent" The method I’m using here is based off an article from David Walsh. Then, in parent.js, we add an event listener for the message. Var message = 'documentHeight:'+documentHeight Add some unique identifier to the string being passed Once we have the height, we can use the postMessage API to send the message to parent.js. We use the height of the main container element instead of just the body because using the body element will cause an infinite loop when we repeat this on the resize of the window (See step 4). var documentHeight = document.getElementById(‘main-element').scrollHeight We do this by getting the scrollHeight of the main element ( #main-element) within the document. In iframe.js, we have to determine the height of the document before we can pass it to the parent document. This sets a container of 100 width that a video embed can.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |