Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 3rd, 2007, 11:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Arlington, TX, USA.
Posts: 119
Thanks: 0
Thanked 1 Time in 1 Post
Default Problem with using showModalDialog

I have been asked to change a javascript function whereby we were opening up a pop-up window and then using an html page to refresh the parent window and then close the pop-up window.

However, now we've been asked to use the showModalDialog when opening up the pop-up window but when we try to use the same html page that refreshed the parent window and closed the pop-up window we are getting the following:

1. A third window (like the parent window) is opening up.
2. And the pop-up window does not close.

Here is the javascript in the html that we were using:

    <script type="text/javascript">
      if (window.opener) {
        window.opener.location.reload();
      }
      window.close();
    </script>

Here is my showModalDialog code:
    window.showModalDialog(u,'addNote','dialogWidth=34 0px;dialogHeight=175px;status=no;scroll=no;resizab le=no');

I've googled and found a lot of suggestions but none are working. Any suggestions or direction would be greatly appreciated.

Regards.
  #2 (permalink)  
Old May 3rd, 2007, 04:30 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Modal dialogues can't refer to their parent using opener. You need to pass a reference to the parent in the second parameter to showModalDialog:
Code:
var oArgs = {opener: self, action: "addNote"};
var returnValue = showModalDialog(u, oArgs, sFeatures)
then inside the dialogue window:
Code:
alert(window.dialogArguments.action);
alert(window.dialogArguments.opener.location.href);
--

Joe (Microsoft MVP - XML)


Similar Threads
Thread Thread Starter Forum Replies Last Post
showModalDialog Problem akhilesh_g Javascript 0 July 14th, 2008 06:43 AM
ShowModalDialog DarrenMelling Javascript How-To 7 February 17th, 2005 11:59 AM
showModalDialog() leion General .NET 3 June 6th, 2004 04:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.