Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
JavaScript and iFrame
Hallo,
i integrate a non Vaadin-Application in my Vaadin Application. I use a Iframe.
The non Vaadin-Application integrates JavaScript Funktions. Here "toAlert()".
I want to click a Vaadin Button and then the JavaScript Funktion toAlert() in the Iframe is called.
Here is my code:
txtHtml.setContentMode(ContentMode.HTML);
txtHtml.setValue("<iframe id='MapFrame' style='width:100%;height:500px;' src='http://localhost:8081/map/map_openlayers_test.html'></iframe>");
cmdManipulateJavaScript.setCaption("JavaScript call");
cmdManipulateJavaScript.addClickListener(new Button.ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
Page.getCurrent().getJavaScript().execute("window.frames[0].toAlert();");
}
});
This code only run in MicrosoftInternetExplorer not in Firefox or Chrome.
How I solve this Problem.
How I call JavaScript code locally on Clint-Side.
Thanks
Patrick
I beliewe window.frames is an IE feature, but this link has code that should work in all browsers:
http://stackoverflow.com/questions/251420/invoking-javascript-code-in-an-iframe-from-the-parent-page
Hallo Thomas,
that was a great tip.
I solved this Problem with:
private Label txtHtml;
...
txtHtml.setContentMode(ContentMode.HTML);
txtHtml.setValue("<iframe [color=#FF0000]id='KartenFrame' name='KartenFrame'[/color] scrolling='no' style='width:96%;height:500px' src='http://localhost:8080/map/map_openlayers_test.html'></iframe>");
Thanks
Patrick