aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Returning Values from Modal Dialog Box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Returning Values from Modal Dialog Box " Watch "Returning Values from Modal Dialog Box " New topic
Author

Returning Values from Modal Dialog Box

Animesh Saxena
Ranch Hand

Joined: Jan 15, 2006
Posts: 62
I am creating a modal dialog box. Everything in the dialog box is modal. I want to return some value from this modal dialog box to the parent window. The problem is it is always returning "UNDEFINED"

If instead of dynamic values i use window.showModalDialog("somepage.htm")
it returns values perfectly from the javascript of the page "somepage.htm".

Since I am forming this html dynamically it is not showing anything when i try to get the value of window.returnValue.

Has anybody come across a similar issue please lemme know?
CANCEL </BUTTON></TD>" +" </TR>"
+" </TABLE>";

var pg="javascript:'<html><head>" + titl + js + "</head><body>"+bdy+"</body></html>'";

var MyArgs = window.showModalDialog(pg,window.self,WinSettings);
//var MyArgs = window.open(pg,'','');

alert(MyArgs);

}

</script>
</HEAD>
</HTML>
[/CODE]


[/CODE]


Animesh Saxena<br /> <br />Open Source Developer
Jon Hanlon
Greenhorn

Joined: May 02, 2006
Posts: 8
In the modal window, the incoming parameters are found in window.dialogArguments
and the return value (result) should be placed in window.returnValue

Back in the main page, the return value (result) is found by
var result = window.showModalDialog(sURL,vArgs,sFeats);
Pavan Keely
Ranch Hand

Joined: Jun 30, 2006
Posts: 62
Animesh,

This is a security restriction on Modal Dialog boxes. Because the main page is accessed using "http" or "file" protocol, where as the modal dialog will have "javascript" pseudo protocol. So, if the protocols are different then they can not communicate. It's the same rule for domains. If dialog box html source is not from the same domain as main page then access then they will not communicate. I think that's the very reason why the return value is always undefined and when you try to access using HTML from the external HTML page, you are able to get the return value.

Hope you know that window.showModalDialog is not supported by Mozilla Firefox or Mozilla based browsers in general.


Pavan Keely<br /><a href="http://keelypavan.blogspot.com" target="_blank" rel="nofollow">http://keelypavan.blogspot.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Returning Values from Modal Dialog Box