how to add IFrameElement to a SimplePanel

40 views Asked by At

i want to create an iframe using javascript and add the returned object from javascript to a simplePanel

i create iframe using this method :

   public static native JavaScriptObject createIframe(String frameId)/*-{enter code here
                                                                                      if($wnd.frames[frameId]!=null){
                                                                            var iframes = $doc.getElementsByTagName(frameId);
                                                                            for (var i = 0; i < iframes.length; i++) {
                                                                            iframes[i].parentNode.removeChild(iframes[i]);
                                                                            }
                                                                            }
                                                                            ifrm = $doc.createElement("IFRAME");
                                                                            ifrm.setAttribute("id", frameId);
                                                                            return ifrm;
                                                                            }-*/;

and use it in this manner:

public void createIFrame() {
    
            SimplePanel frameContainer = new SimplePanel();
        
        IFrameElement frame= createIframe(FRAME_ID).cast();

        frame.setId(FRAME_ID);
        frameContainer.clear();
        frameContainer.setWidth("100%");
            frameContainer.setHeight("100%");
//add frame to frameContainer
        
    }

now ,how can I add frame to frameContainer

1

There are 1 answers

0
Andrei Volgin On BEST ANSWER

You can use:

frameContainer.getElement().appendChild(frame);