Vehicle energy consumption and production simulator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

26 lines
764 B

document.addEventListener('DOMContentLoaded', function() {
let frame = <HTMLIFrameElement>document.querySelector('iframe#simulator');
let doc = frame.contentWindow.document;
frame.style.width = '100%';
frame.style.border = 'none';
frame.setAttribute('scrolling', 'no');
// Insert HTML code in the iframe
doc.open();
doc.write((<any>window)['simulator.html']);
doc.close();
// Load iframe specific CSS
doc.head.innerHTML += (<any>window)['simulator-in-iframe.css'];
// Add script inside frame
let script = doc.createElement('script');
script.type = "text/javascript";
script.innerText = (<any>window)['app.js'];
doc.body.appendChild(script);
setInterval(() => {
frame.height = Math.max(doc.body.scrollHeight, 700) + 'px';
}, 100);
});