Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elemental2.dom.Window is missing document variable #60

Open
mseele opened this issue Jul 9, 2018 · 5 comments
Open

elemental2.dom.Window is missing document variable #60

mseele opened this issue Jul 9, 2018 · 5 comments

Comments

@mseele
Copy link

mseele commented Jul 9, 2018

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;
}-*/;
@jDramaix
Copy link
Member

Contribution is welcome here.

This can be easily fixed by

@softweaver
Copy link

We already have:

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

@jDramaix
Copy link
Member

jDramaix commented May 1, 2019

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.

@lofidewanto
Copy link

lofidewanto commented Oct 29, 2020

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

@jDramaix
Copy link
Member

jDramaix commented Nov 2, 2020

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(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants