Jens, thank you very much!
You helped me a lot! It works fine.

For others, who have the same problem, here is the working code (JSNI 
method):
public native boolean optimizeFrameSize (String id)
    /*-{
            var newheight;
            var newwidth;
            var frame = $doc.getElementById(id)
        
            if(frame !=null){
                newheight=frame.contentWindow.document.body.scrollHeight;
                newwidth=frame.contentWindow.document.body.scrollWidth;
                frame.height= (newheight) + "px";
                frame.width= (newwidth) + "px";
                return true;
            }
           
            return false;
    }-*/;

Also addLoadHandler works fine!


*One more question for the IFrame:*
Is there a way to get with an IFrame the same scroll-experience with an 
HTML-widget?
The reason:
The content of the IFrame is always selectable and so scrolling works only 
on the left or right side on the screen of a mobile device (I use the 
IFrame for an mgwt-app).
If the text would be not selectable (but links are touchable) as in 
HTML-widgets, I would have the same scroll-experience (users can scroll by 
touching the content with one finger - and not only on right or left side 
of the screen) on my displayed IFrame.


Am Mittwoch, 15. Januar 2014 20:32:42 UTC+1 schrieb Jens:
>
> 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?
>>
>
> $doc is correct because you are in a GWT app. GWT is executed in an iFrame 
> and if you would only write "document" you would get the iFrame document 
> and not the window document. Same with $wnd. So in a GWT app you always use 
> $wnd and $doc inside JSNI functions to access the top level window and 
> document.
>  
>
> 2)
>> After that I should wait until the frame content is fully loaded. 
>> => How can I handle this??  
>>
>
> Frame.addLoadHandler(). 
>
>  
>
>> 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;
>>
>
> As already said in my previous reply: $doc is a GWT variable and if your 
> Frame does not show a GWT app then this variable does simply not exist in 
> that Frame. Instead of $doc you then have to use "document": 
> frame.contentWindow.document.body.scrollWidth.
>
>
> -- 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.

Reply via email to