Zuh*_*aib 17 asp.net iframe modalpopupextender
我的主页里面有一个iframe.iframe页面中有一个modalpopup.因此,当显示modalpopup时,modalpopup的父级是iframe主体和主页面父主体.因此,叠加层仅覆盖iframe而不是整个页面.
我尝试使用jQuery将modalpopup从iframe移动到父窗口body元素(或父窗体内的任何其他元素).我收到一个无效的参数错误.
如何从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
}
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你
小智 1
如果您只是将 iframe 用于可滚动内容,您可能会考虑使用带有Overflow: auto或scroll 的样式化 div 。
这样的设置可以更轻松地修改整个页面的外观,因为您不需要处理多个文档,每个文档在页面内本质上都有自己的窗口空间。您可以绕过一些跨框架通信,如果需要的话,保持信息同步可能会更容易。
这可能并不适合所有情况,并且可能需要 ajax(或使用 javascript 修改 dom)来更改 div 内容,而不是仅仅在 iframe 中加载不同的文档。此外,一些较旧的移动浏览器(例如 Android Froyo 版本)不能很好地处理可滚动的 div。