So i have a small react component which renders an iframe. I need to determine when all the content (html etc) has fully loaded.
The iframe is loading an orbeon form which can takes a few seconds to fully load.
I have tried hooking into the 'load' event form the iframe which works but triggers the even the second the iframe is loaded and not when the iframes content has loaded.
I have read some posts about listening to the 'DOMContentLoaded' even but cannot seem to get that to work.
here is the react component which renders the Iframe.
basically I need to trigger the documentDrawerLoaded function once all of the iframe content has been rendered.
return React.createClass({
displayName: 'FilePickerColourSelector',
getInitialState: function() {
return {
listVisible: false
};
},
componentWillMount: function () {
console.log('loading...')
},
componentDidMount: function () {
this.refs.documentDrawer.getDOMNode().addEventListener('load', this.documentDrawerLoaded);
},
documentDrawerLoaded: function () {
console.log('drawer has been loaded');
document.getElementById('js-document-drawer-overlay').classList.toggle('active');
document.getElementById('js-document-drawer').classList.toggle('active');
},
render: function() {
var documentDrawerStyles = {
height: '100%',
width: '100%',
border: 'none'
}
return <iFrame
src={this.props.url}
style={documentDrawerStyles}
ref="documentDrawer"
scrolling="no"
>
</iFrame>;
},
});