Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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.
Reply With Quote
  #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)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:16 PM.


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