Solved

Modal IE dialog calling function in parent

Posted on 2008-06-19
3
1,368 Views
Last Modified: 2008-10-01
Experts:
I have a modal IE dialog opened by the snippet below. I would like the modal to call a javascript function in the parent IE window on close, with something like this
<INPUT type=button value=Close onClick="javascript:window.opener.focus();window.opener.Navigate(EventID);">
The problem is that i get an error, stating that window.opener is null or not an object. I am open to different solutions, as long as I can on close of the modal call my function in the parent.


Thanks for you help

<html>
<head>
<form method="post" action="test2.asp" name="ErrorCheck">
<title>Test</title>
<SCRIPT language="javascript">
function modalWin() {
if (window.showModalDialog) {
window.showModalDialog("errordisplay2.asp?","Error","dialogWidth:350px;dialogHeight:500px");
} else {
window.open("errordisplay2.asp?","Error","height=350,width=500,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes");}
}
function Navigate(EventID)
{
document.frmNavigate.action="ADCheck.asp"
document.frmNavigate.EventID.value=EventID;
document.frmNavigate.submit();
}
window.onload = modalWin;
</SCRIPT>
</head>
</body>
</html>

Open in new window

0
Comment
Question by:yommm
3 Comments
 
LVL 9

Expert Comment

by:djon2003
ID: 21828141
Here is a page explaining the use of Opener and another way of doing a navigation of the parent page :
http://www.webreference.com/js/tutorial1/opener.html
0
 
LVL 22

Expert Comment

by:neeraj523
ID: 21828735
Hello

Modal Dialog is something which is compatible with only IE (as per my knowladge). Why dont you use window.open method ??

You can call a function from the parnent window on close of this pop window like this..

<body onBeforeUnload="opener.Navigate("arg")">
pop up Window
</body>
0
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 500 total points
ID: 21830504
Opening a modal window in IE will stop executing Javascript right after the call showModalDialog.
After the modal closes scripting continues, n fact showModalDialog is a function which returns a vaule.

EventID = window.showModalDialog("errordisplay2.asp?","Error","dialogWidth:350px;dialogHeight:500px");
if(EventID != null)
Navigate(EventID)

If a specify a window.returnValue property while closing the dialog, scripting from the calling window continues...

In case of multi browser situation you have to determine whether the popup is modal (IE) or not.
(Just check if window.opener != null)
To close the dialog (in your case it's handled by a button) you have to say :

window.returnValue = EventID;
self.close();
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question