sách gpt4 ai đã đi

asp.net - 将ModalPopup移动到IFrame之外。可能?

In lại 作者:行者123 更新时间:2023-12-03 14:25:22 30 4
mua khóa gpt4 Nike

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

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

如何在iframe中的页面上显示一个modalpopup,它应该覆盖整个文档以及父文档?

更新:

由于很少有用户对实现相同的行为感兴趣。因此,这里是解决方法

我建议最好的解决方法是在主页上有modalpopup,然后从iframe调用它。

/* 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
}


希望能帮助到你

1 Câu trả lời

如果您仅将iframe用于可滚动内容,则可以考虑使用具有溢出功能的div样式:自动或滚动。

这样的设置使您可以更轻松地修改整个页面的外观,因为您不需要使用多个文档,而每个文档在页面内部实际上都有各自的窗口空间。您可以绕过某些跨框架通信,如果需要,可以使信息保持同步更加容易。

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

关于asp.net - 将ModalPopup移动到IFrame之外。可能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/295621/

30 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com