English 中文(简体)
在加装后
原标题:Resize iframe after adding in on load

在用javascript装货后,我会遇到重整一片子的麻烦。 我使用一套约300页的宽度,这些宽度可进行细微工作,但能动态地大小乘机的高度,使之达到内容的大小(博客员额)。

我尝试把内容(没有孩子主宰部分)和内容文件(未经界定)看不出。

我在负荷上这样做:

var iframe = document.createElement( iframe ); 
iframe.setAttribute( id , postFrame ); 
iframe.setAttribute( frameborder , no ); 
iframe.setAttribute( scrolling , no ); 
iframe.setAttribute( onload , resizeFrame(); ); 
iframe.setAttribute( width , 300px ); 
iframe.setAttribute( src , http://espn.go.com/espn/print?id=7454651 ); 
var container = document.getElementById( container ); 
container.appendChild(iframe);


function resizeFrame(){ /* resize iframe based on content height*/ }

是否有办法根据机体内的内容重划机尺寸?

<><><>>><>>>>>_>EDIT**

可能的工作:

是否有希望能够利用“准入-信任”来协助这一问题? 让我们说,在座的那页是我自己的,或者是来自一个营地的文字。

最佳回答

I use the following function to resize an iframe to be the height of the content. It s for an intranet app (and only properly tested in IE8) but certainly works so it might provide the missing clue-

function sizeIframeToContent(id) {
    // resize iframe to be the height of the content
    try {
        var frame = document.getElementById(id);
        innerDoc = (frame.contentDocument) ?
                   frame.contentDocument : frame.contentWindow.document;
        var objToResize = (frame.style) ? frame.style : frame;
        objToResize.height = innerDoc.body.scrollHeight + 10 +  px ;
        //objToResize.width = innerDoc.body.scrollWidth + 10 +  px ;
    }
    catch (err) {
        console.log(err.message);
    }
}

Edit 解释:一旦文件装上你,就应当能够找到文件高峰,然后作为文件顶顶。 我评论了上述职能的宽宏部分,因为你再次具体询问了高度。

问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签