Solved

Modal IE dialog calling function in parent

Posted on 2008-06-19
3
1,360 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Add Background to a PDF Programmatically 1 24
jQuery animation faster 1 17
Java Server Faces parameter pass? 6 22
onOpen 14 42
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 …
Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
This video teaches users how to migrate an existing Wordpress website to a new domain.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now