Blogger Widgets
  • Sharing Photos using SignalR
  • TFS Extenstion - allows copy work items between projects
  • Displaying jquery progressbar with ajax call on a modal dialog
  • Managing windows services of a server via a website
  • Exploring technologies available to date. TechCipher is one place that any professional would like to visit, either to get an overview or to have better understanding.

Search This Blog

Wednesday 5 January 2011

Passing vArguments or dialogArguments with window.open

Arguments can only be passed with window.showModalDialog which is quite helpful. But consider your application is using these arguments extensively in your website and suddenly it appears modal dialog is not supported on all browsers. Opera does not support modal dialog, now instead of changing the existing functionality the work around would be as follows:-

1. Detect if browser support modal dialog or not and then assign arguments
var vArguments = new Object();
vArguments.test1 = "test1 data";
vArguments.test2 = "test2 data";
if (window.showModalDialog) {
window.showModalDialog(sURL, vArguments, sFeatures);
}
else
{
window.dialogArguments = vArguments;
window.open(sURL, "_blank", sFeatures);
}

2. Now inside the pop-up window access the arguments

 var dialogArguments ;
if (window.showModalDialog) {
 dialogArguments = window.dialogArguments;
}
else {
 dialogArguments = window.opener.dialogArguments;
}
alert(dialogArguments.test1);
alert(dialogArguments.test2);

Now this should work like a charm.


Man is still the most extraordinary computer of all. ~John F. Kennedy
Copyright © 2013 Template Doctor . Designed by Malith Madushanka - Cool Blogger Tutorials | Code by CBT | Images by by HQ Wallpapers