Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 823
  • Last Modified:

Get the Returned value from a JavaScript showModalDialog then close the dialog.

I am trying to return the showModalDialog's returnValue.  In the aspx page that I'm using for my dialog, I'm trying to set the window.returnValue then close the dialog.  When I run this I get an error stating that the property returnValue doesn't exist in the current object.  How on earth am I going to get the return value out of the dialog if the returnValue doesn't exist?  I am doing this in a .NET 1.1 web application.

All I want to do is call the dialog to confirm something with a "Yes" or "No" response then close the dialog and pass the value back to the calling page.

Please advise.
Here is the JavaScript to call the dialog:
var retVal = window.showModalDialog(dialogURL, args, options);									
if (retVal != null)
{
	if(retVal.split(',')[1] == true)
	{
		bolReturn = true;
	}
	else
	{
		bolReturn = false;
	}
}
 
Here is the script in the dialog page:
function Confirmation(choice)
{
	try
	{
		returnValue = choice;
	}
}

Open in new window

0
pldougless
Asked:
pldougless
  • 3
  • 2
1 Solution
 
rbradberryCommented:
"returnVallue = choice;" should be "window.returnValue = choice;"

also, this is an IE only function, it will not work in FireFox
0
 
pldouglessAuthor Commented:
Sorry, the code should have reflected window.returnValue.  I have tried "window.returnValue" and get the error when I do.  Also, when coding and using intellisense I don't see the returnValue member in the window object...it simply isn't there.
0
 
rbradberryCommented:
are you calling that function from within the window?  window.returnValue is only available after the windows has closed.
0
 
rbradberryCommented:
basically you have to set the window.returnValue from within the window while it is open.  then you can only retrieve the value of after the window has closed.
0
 
pldouglessAuthor Commented:
I am trying to set the window.returnValue in the dialog before it is closed...here is what I doing in the windows script:

Here is the script in the dialog page:
function Confirmation(choice)
{
      try
      {
            window.returnValue = choice;
            window.close();
      }
}

The error is encountered saying that the returnValue property doesn't exist.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now