Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Modal IE dialog calling function in parent

Posted on 2008-06-19
3
Medium Priority
?
1,388 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1500 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

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

636 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