Invoke Javascript in embeded html

Hi,

I have an external html page embedded in vaadin. What I need is: when triggering the listeners of the vaadin UI components, the javascripts in the embedded html page can be executed.

I read that the embedded html are within an iframe. If I am able to obtain the element id of this iframe. Should I be able to do the following?

getWindow().executeJavaScript(“document.getElementById('” + iframeId + “').contentWindow.myJsFunction();”);

If this is possible, my 2nd question is whether it is possible to obtain the iframe id in vaadin? Or the GWT obfuscator does a great job to prevent me from doing so?

Many Thanks.

I have figured out how to do it. The following is what I have done. I hope it helps if other people have similar problems.

It requires to pass a piece of javascript code to the executeJavaScript() function.

In this piece of JS code. I did

  1. iterate through window.frames, which contain the iframe that embeds my external html.
  2. for each frame, i obtain the tile of the frame: myframe.document.title. If the external html contains a tag. myframe.document.title should contain the value of the tag. so I can find which frame is the iframe that contains my external html page.
  3. call myframe.myJsFunction()

I can see my WebGL 3D cubes start rotating if I click a vaadin button that executes the above JS code. :grin: