Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    HTML iframe height 100 percent

    Hi! There is a little sample code for iframe height:100%. (Testing the fix height="555px" works ok but it is not the function what we want). I would like to resize this part of window dynamically using the resize bar so that the child should have height=100%. You can compare the attached screens. What are the right settings to show it in 100 percent size?

    Code:
    [B]import[/B] com.google.gwt.user.client.ui.HTML;
    [B]import[/B] com.smartgwt.client.types.Overflow;
    [B]import[/B] com.smartgwt.client.widgets.Canvas;
    [B]import[/B] com.smartgwt.client.widgets.Window;
    
    [B]public[/B] [B]class[/B] TestWin [B]extends[/B] Window {
          [B]public[/B] TestWin() {
                String heightValue = "100%"; // "555px"; // "100%"
                setTitle("Test Window iframe height:" + heightValue);
                setWidth100();
                setHeight100();
                String url = "http://localhost/";
                String html = "<iframe style=\"border:0px;height:" + heightValue
                            + ";width:100%\" src=\"" + url + "\" id=\"test\"></iframe>";
                HTML child = [B]new[/B] HTML(html);
                child.setWidth("100%");
                child.setHeight("100%");
                Canvas canvas = [B]new[/B] Canvas();
                canvas.setCanDragResize([B]true[/B]);
                canvas.setShowResizeBar([B]true[/B]);
                canvas.addChild(child);
                canvas.setOverflow(Overflow.[B][I]HIDDEN[/I][/B]);
                addMember(canvas);
          }
    }
    FF ESR 24.8.1
    IE 11 Version 11.0.9600.18283, Update 11.0.30 (KB3148198)
    GWT version : 2.5.1, 2.6
    SmartGWT version : 6.0p (Tue Apr 12 14:38:00 GMT+200 2016)
    Attached Files

    #2
    There's no need for any of this, use an HTMLFlow or HTMLPane and the iframe is automatically managed.

    Managing it yourself would involve a bunch of platform-specific JSNI you don't want to get into.

    Comment


      #3
      Please, how can I set the url for HTMLPane without exception: Cannot change configuration property 'contentsType' to page now that component isc_HTMLPane_0 has been created.
      Code:
      [B]import[/B] com.smartgwt.client.widgets.HTMLPane;
      [B]import[/B] com.smartgwt.client.widgets.Window;
       
      [B]public[/B] [B]class[/B] TestWin [B]extends[/B] Window {
            [B]public[/B] TestWin() {
                  HTMLPane pane = [B]new[/B] HTMLPane();
                  pane.setIFrameURL("http://localhost/");
            }
      }

      Comment


        #4
        I use pane.setContentsURL("http://url") and it works fine

        Comment


          #5
          Thank you all for the answers. Yes, it works fine for the sample url.
          Code:
          [B]import[/B] com.smartgwt.client.types.ContentsType;
          [B]import[/B] com.smartgwt.client.types.Overflow;
          [B]import[/B] com.smartgwt.client.widgets.Canvas;
          [B]import[/B] com.smartgwt.client.widgets.HTMLPane;
          [B]import[/B] com.smartgwt.client.widgets.Window;
           
          [B]public[/B] [B]class[/B] TestWin [B]extends[/B] Window {
                [B]public[/B] TestWin() {
                      setTitle("Test Window HTMLPane");
                      setWidth100();
                      setHeight100();
           
                      HTMLPane pane = [B]new[/B] HTMLPane();
                      pane.setContentsType(ContentsType.[B][I]PAGE[/I][/B]);
                      pane.setContentsURL("http://www.smartclient.com/");
                      pane.setWidth100();
                      pane.setHeight100();
           
                      Canvas canvas = [B]new[/B] Canvas();
                      canvas.setCanDragResize([B]true[/B]);
                      canvas.setShowResizeBar([B]true[/B]);
                      canvas.addChild(pane);
                      canvas.setOverflow(Overflow.[B][I]HIDDEN[/I][/B]);
                      addMember(canvas);
                }
          }

          Comment

          Working...
          X