首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将ModalPopup移出IFrame。有可能吗?

将ModalPopup移出IFrame。有可能吗?
EN

Stack Overflow用户
提问于 2008-11-17 14:01:54
回答 4查看 6.8K关注 0票数 17

我的主页里有一个iframe。在iframe页面中有一个modalpopup。因此,当modalpopup显示时,modalpopup的父级是iframe主体和主页的父级主体。因此,覆盖只覆盖iframe,而不是整个页面。

我尝试使用jQuery将modalpopup从iframe移动到父窗口主体元素(或父主体内的任何其他元素)。我收到一个无效参数错误。

如何在iframe中显示页面中的modalpopup,并且它应该覆盖整个文档,父文档也是如此?

更新:

由于很少有用户对实现相同的行为感兴趣..以下是解决方法

我建议的最好的解决办法是在主页中显示modalpopup。然后从iframe调用它..这样说吧..

代码语言:javascript
复制
/* function in the main(parent) page */
var _onMyModalPopupHide = null;
function pageLoad(){
    // would be called by ScriptManager when page loads
    // add the callback that will be called when the modalpopup is closed
    $find('MyModalPopupBehaviorID').add_hidden(onMyModalPopupHide);
}
// will be invoked from the iframe to show the popup
function ShowMyModalPopup(callback) {
    _onMyModalPopupHide = callback;
    $find('MyModalPopupBehaviorID').show();
}
/* this function would be called when the modal popup is closed */
function onMyModalPopupHide(){
    if (typeof(_onMyModalPopupHide) === "function") {
        // fire the callback function
        _onMyModalPopupHide.call(this);
    }
}

/* functions in the page loaded in the iframe */
function ShowPopup(){
    if(typeof(window.parent.ShowMyModalPopup) === "function") {
        window.parent.ShowMyModalPopup.apply(this, [OnPopupClosed]);
    }
}
// will be invoked from the parent page .. after the popup is closed
function OnPopupClosed(){
    // do something after the modal popup is closed
}

希望能有所帮助

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2011-09-13 07:33:34

如果你只是将iframe用于可滚动的内容,你可以考虑一个带有overflow的样式化div : auto或者scroll

这样的设置使修改整个页面的外观变得更容易,因为您不需要处理多个文档,每个文档实际上在页面中都有自己的窗口空间。您可以绕过一些跨帧通信,如果需要,保持信息同步可能会更容易。

这可能并不适用于所有情况,并且可能需要ajax (或使用javascript修改dom )来更改div内容,而不仅仅是在iframe中加载不同的文档。此外,一些较旧的移动浏览器,如Android Froyo版本,不能很好地处理可滚动的div。

票数 1
EN

Stack Overflow用户

发布于 2011-09-22 23:55:12

您在更新中回答了自己的问题。模式对话框需要存在于父页面上,并从iframe调用。您唯一的其他选择是使用滚动div而不是iframe。

票数 0
EN

Stack Overflow用户

发布于 2011-10-02 01:52:47

你这样问是不可能的。这样想: iframe是一个独立的窗口。您暂时不能将一个网页中的div移到另一个网页中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/295621

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档