elemental2 icon indicating copy to clipboard operation
elemental2 copied to clipboard

elemental2.dom.Window is missing document variable

Open mseele opened this issue 5 years ago • 5 comments

I'm trying to access the document from a elemental2.dom.HTMLIFrameElement but noticed that elemental2.dom.Window (via HTMLIFrameElement.contentWindow) has no document variable. There is no chance to access an iframe document via elemental2.

This should be possible. Please see more details in the example at https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/contentWindow

I need to solve that via native gwt code:

public final native elemental2.dom.Document document(elemental2.dom.Window contentWindow) /*-{
	return contentWindow.document;
}-*/;

mseele avatar Jul 09 '18 12:07 mseele

Contribution is welcome here.

This can be easily fixed by

jDramaix avatar Mar 12 '19 00:03 jDramaix

We already have:

import static elemental2.dom.DomGlobal.document; import static elemental2.dom.DomGlobal.window;

softweaver avatar May 01 '19 22:05 softweaver

You are right but DomGlobal.document and DomGlobal.window are targeting the global document and window objects. The goal is to access document from any Window object that could potentially comes from an IFrame.

jDramaix avatar May 01 '19 22:05 jDramaix

I have a question to this problem. So, at the moment I cannot register an event like onclick to an iFrame, is that correct?

Thanks

lofidewanto avatar Oct 29 '20 14:10 lofidewanto

If you need to access the body, you can still work around this problem by using jsinterop-base:

import jsinterop.base.Js;

HTMLBodyElement iframeBody = Js.asPropertyMap(iframe.contentWindow).get("body");
iframeBody.addEventListener(...)

jDramaix avatar Nov 02 '20 18:11 jDramaix