Thank you! If I understand all correct: 1) in my ViewImpl-Class in the Consructor I have to create the frame and load the content. The content (html-url) is from my war-directory: frame = new Frame(GWT.getHostPageBaseURL() + "ClientData/myhtml.html"); frame.getElement().setId("framename"); => $doc is right here because it is in my domain?
2) After that I should wait until the frame content is fully loaded. => How can I handle this?? For testing I added a Button in my ViewImpl-Class. After clicking(tap) the button, I call the setFrameSize method with the correct id. optimizeFrameSize("framename"); 3) If the content is loaded I call the setFrameSize()-Method. public native boolean setFrameSize (String id) /*-{ var newheight; var newwidth; var frame = $doc.getElementById(id) if(frame !=null){ newheight=frame.contentWindow.$doc.body.scrollHeight; newwidth=frame.contentWindow.$doc.body.scrollWidth; frame.height= (newheight) + "px"; frame.width= (newwidth) + "px"; return true; } return false; }-*/; (The old code was from internet. I never coded JS before.) After the three steps I get the following exception-text ("property 'body'"?): uncaught: Exception caught: Exception caught: (TypeError) @xyz.client.views.experimental.FrameViewGwtImpl::optimizeFrameSize(Ljava/lang/String;)([string: 'framename']): Cannot read property 'body' of undefined Am Mittwoch, 15. Januar 2014 16:58:24 UTC+1 schrieb Jens: > > You must first add the Frame to the document > otherwise doc.getElementById() can not find it. You also have to wait until > the frame content is fully loaded before reading any size related values. > > Finally your setFrameSize() seems not optimal. You call 4x > getElementById() instead of just 1x (keep a reference of the found element) > and the if() does not protect you from anything as you call > $doc.getElementById inside and outside the if(). > > Finally as a reminder: $doc is a special GWT variable so if your frame > content is not a GWT app then calling $doc inside the frame will not work. > > -- J. > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at http://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/groups/opt_out.