admin管理员组文章数量:1332201
Is there a way to detect when a page has been loaded in a modal dialog? Such as when you call window.showModalDialog().
A little background: I'm trying to get around the Forms Authentication problem of the login page appearing in the modal dialog, and subsequently the rest of the site when the user logs in.
Any ideas?
Is there a way to detect when a page has been loaded in a modal dialog? Such as when you call window.showModalDialog().
A little background: I'm trying to get around the Forms Authentication problem of the login page appearing in the modal dialog, and subsequently the rest of the site when the user logs in.
Any ideas?
Share Improve this question edited May 1, 2013 at 16:23 Zachary Yates asked May 27, 2009 at 19:54 Zachary YatesZachary Yates 13.4k7 gold badges59 silver badges89 bronze badges1 Answer
Reset to default 6For window.open you could check to see if the page you are currently on has a parent.
function parentExists(){
return (window.opener != null)? true : false;
}
Call this when your login page loads. If it returns true, you are in a popup window (or modal). You can then close the page and redirect the parent.
It's a little more tricky for a modal box because you don't have access to the opener. First, make sure all modal boxes are opened similar to this:
window.showModalDialog('test.htm', self, <optional options>);
This will make sure something is passed into the window's arguements.
Now add the following code on your login page:
function parentExists()
{
var opener = window.dialogArguments;
return (opener == null)?false:true;
}
Edit: added information on modal boxes
本文标签: Detecting modal dialogs in javascriptStack Overflow
版权声明:本文标题:Detecting modal dialogs in javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742239915a2438765.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论