我的主页中有一个 iframe。iframe 页面内有一个 modalpopup。所以当modalpopup显示出来的时候,modalpopup的父级就是iframe body和main page parent body。因此,覆盖仅覆盖 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
}
希望能帮助到你