Created
February 12, 2020 19:25
-
-
Save branflake2267/d5cd1f67e6f7e2ae43c5043659c9771b to your computer and use it in GitHub Desktop.
GXT remove iframe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sencha.gxt.test.client._northgate; | |
import com.google.gwt.core.client.EntryPoint; | |
import com.google.gwt.core.client.GWT; | |
import com.google.gwt.core.client.JavaScriptObject; | |
import com.google.gwt.dom.client.Document; | |
import com.google.gwt.dom.client.Element; | |
import com.google.gwt.dom.client.IFrameElement; | |
import com.google.gwt.dom.client.NodeList; | |
public class IframeReferenceSandbox implements EntryPoint { | |
protected static class IFrameElementExt extends IFrameElement { | |
protected IFrameElementExt() { | |
} | |
public final native JavaScriptObject getWindow() /*-{ | |
return this.contentWindow; | |
}-*/; | |
public final native void clear() /*-{ | |
this.src = ''; | |
// this.contentWindow.document.write(''); | |
// this.contentWindow.close(); | |
}-*/; | |
} | |
@Override | |
public void onModuleLoad() { | |
NodeList<Element> iframes = Document.get().getElementsByTagName("iframe"); | |
if (iframes != null) { | |
for (int i=0; i < iframes.getLength(); i++) { | |
GWT.log("iframe " + i); | |
// option 1 | |
// IFrameElement iframe = iframes.getItem(i).cast(); | |
// iframe.setSrc("about:blank"); | |
// | |
// Document document = iframe.getContentDocument(); | |
// document.removeAllChildren(); | |
// | |
// Document.get().removeChild(iframe); | |
// option 2 | |
IFrameElementExt iframe2 = iframes.getItem(i).cast(); | |
iframe2.clear(); | |
iframe2.removeFromParent(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment