开发者

Viewport resizing within an iFrame

I'm trying to create a Carrousel in Sencha which displays iframes.

The basic idea is that I have a bunch of HTML files already configured to be viewed on an iPad.

So the files have a viewport and everything configured.

I created a simple carrousel like this :

var rootPanel;
Ext.setup({
    onReady: function() {
        rootPanel = new Ext.Carousel({
            fullscreen: true,
            layout: 'card',
            items: [
                { html: '<iframe src="http://localhost/file1.html">' },
                { html: '<iframe src="http://localhost/file2.html">' },
                { html: '<iframe src="http://localhost/file3.html">' },
            ]
        });
    }
});

The HTML files themselves look like this :

<!DOCTYPE html>
  <html>
    <head>
        <title>Untitled Page</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width; initial-scale=0.5; minimum-scale=0.5; maximum-scale=1.0;user-scalable=no">
    </head>
    <body>
        <div id="container">
            <div style="margin:0;padding:0;position:absolute;left:0px;top:0px;width: 1536px; height: 2048px;text-align:left;z-index:0;">
                <img src="image.jpg" style="width: 1536px; height: 2048px;"></div>
开发者_开发技巧        </div>  
    </body>
</html>

The system sort of works, except that the viewport is not respected and the inside of the iframe is not zoomed out like it's supposed to be. Any idea ?


I'm not familiar with sencha, but iframes don't have the ability to set height to a percentage (100%). So if sencha is setting the width and height to 100%, it won't expand vertically, but should fill the parent horizontally.

Is this what you see?

Try setting the iframe's height manually to a large enough size in px. If you have control of the iframe's content, then you can add a bit of javascript to communicate with the parent and tell it to resize appropriately.


Set 100% on iframe and inner html

var rootPanel;
Ext.setup({
    onReady: function() {
        rootPanel = new Ext.Carousel({
            fullscreen: true,
            layout: 'card',
            cls: 'some-cards',
            items: [
                { html: '<iframe width="100%" height="100%" src="http://localhost/file1.html">' },
                { html: '<iframe width="100%" height="100%" src="http://localhost/file2.html">' },
                { html: '<iframe width="100%" height="100%" src="http://localhost/file3.html">' },
             ]
        });
    }
});

And you css be link something like this.

.some-cards .x-innerhtml {
    height: 100%;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜