closing modal window in IE not closing Embedded resource in it

I have a PDF document and i want to show the document in the modal window. So i have created a Embedded Resource and added it to the window. It opens fine. When i close it (by clicking X button on top right) from IE browser, it closes the window but the PDF document remains there. It stays on the browser like a popup. As i created modal window, i cannot access the other portions of the page. The only way to get out of this is by refreshing the page.
It happens only IE browsers(i have v9).

//SAMPLE CODE....
     VerticalLayout verticalLayout=new VerticalLayout();
       Embedded embeddedResource = new Embedded("", new ExternalResource(UrlOfThePdf));
	embeddedResource.setHeight("630px");
		embeddedResource.setWidth("650px");
		embeddedResource.setMimeType("application/pdf"); 
		embeddedResource.setType(Embedded.TYPE_BROWSER);
    		verticalLayout.addComponent(embeddedResource);
	    		verticalLayout.setComponentAlignment(embeddedResource,Alignment.MIDDLE_CENTER);

This verticalLayout is later added to a modal window.
Any idea…how to address this.[i]

[/i]

Which Vaadin version are you using?
There were/are several issues with embedded pdfs blocking windows (as described
here
and
here
) but your problem is new to me.

You could try to add a WindowCloseListener to your window and hide (setVisible(false)) or remove the Embedded(verticalLayout.removeComponent(embeddedResource)) in the close method.

I am using vaadin 6. But i see the same problem in vaadin 7 too( running on a different machine). I have tried writing CloseListener and overriding the ‘close()’ method. I have tried removing all components for the window in those methods. Did not work. I could still see the PDF is not closed. It still sticks on the page.
I have found another artilce on this, but there is no answer for this.

http://stackoverflow.com/questions/6745133/in-vaadin-pdf-does-not-work-in-popup-window

It happens only in IE browsers. Works fine in Firfox and Chrome. Does this require any browser specific plugins… I can upgrade my browser and see, But we should support IE 9 too.

Do we have any other options of opening PDF apart from using Embedded object…?

I had a similar problem with Vaadin 7 version and IE 11 browser .

Can any one help me with this.

Thanks

As InternetExplorer is not able to call remove() on a DOM Element, this one should do the trick in your CloseWindowEvent:

Just getting the parent, and removing the child.

windowToClose.getUI().getPage().getJavaScript().execute(“var window = document.getElementsByClassName(‘v-window’)[0]
; window.parentElement.removeChild(window);”);

remove the iframes too, by doing this:

windowToClose.getUI().getPage().getJavaScript().execute("var container = document.getElementsByClassName(‘v-overlay-container’)[0]
; var iframeChildren = container.getElementsByTagName(‘iframe’); if(iframeChildren){for(var i = 0; i < iframeChildren.length; i++){container.removeChild(iframeChildren[i]
);}}
");