English 中文(简体)
改变文件规模时的iframe
原标题:Resizing iframe when document changes size

我有一个网页,申请在iframe(同一领域)运行。 单体高度是根据撞击文件高度确定的。 问题是,如果影响的文件规模发生变化(通过扩大协议、菜单等)。 当发生这种情况时,是否有事件发生,我可以相应地利用机面部分进行改装?

我试图把窗户的转播活动捆绑起来,但由于窗户在文件内容发生变化时没有重新铺面,事件突然发生。 我需要的是在文件标的上进行某种转播,但就我所知,没有这样做。 是否有另一种办法检测文件高度的变化?

我不理解一般解决办法,因为我不知道框架的内容,但我可以在其中列入通用文字。

问题回答

There are resize events fired for the iframe window. You can listen to them (in the iframe itself) and than trigger some function in the parent window to propagate new size and update the iframe size in the parent window.

您是否尝试使用<代码>scroll活动,并附上其内容 iFrame的窗口?

Otherwise I would rather suggest you hook directly into the accordion rather than relying on catching scroll events that may or may not happen. Because scroll will only fire once the user actually scrolled the slider, not when the accordion expands..

但是,当用户扩大同意范围时,你可以简单地向母提出一种方法。

我找到了一种可行但并非理想的解决办法,而且在所有浏览器中都没有工作:

By binding to the body element s DOMSubtreeModified in the iframe, I can find the iframe element in parent or top and change it s height.

$( body ).bind( DOMSubtreeModified , function(){
    top.document.getElementById( appFrame ).height = $(document).height();
});

Here s an overview of the browser support for this event: http://www.quirksmode.org/dom/events/

如果你使用j Query ui,你可以使用<条码>交换<>条码>和电话功能>。

setHeight

http://jqueryui.com/demos/accordion/

function setHeight() {
    parent.document.getElementById( the-iframe-id ).height = document[ body ].offsetHeight;
}




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签