There is a possibility to send information without reloading the iframe. In the same way you can receive information from the iframe.
Sending event:
<body>
<iframe id="iframe" src="https://iframe.hogs.live/"></iframe>
</body>
<script>
const iframe = document.getElementById('iframe');
function sendEventToIframe(data) {
iframe.contentWindow.postMessage(data, '*');
}
sendEventToIframe('sth');
</script>
Receiving event
window.addEventListener('message', (event) => {
console.log('Dane z iframe: ', event.data);
});
Event model
interface Event {
type: string;
data: any;
}
Eventy przyjowane przez iframe’a
| Name | Data | Comments |
| calculateRoute | option parameter value for mode= calculateRoute | Route plotting request |
| setLang | ENG | DEU | CZE | ESP | FRA | POL | RUS | UKR | Dynamic languege change. Requesting new map render |
Eventy emitowane
| Name | Data | Comments |
| calculationSucces | format described here | Emit with information about plotted route |
| error | Error message | |
| warning | Warning message |