WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 Window showModaldialog HELP, Logan, January 26, 2004
     Re:Window showModaldialog HELP, Gianna, January 27, 2004
         Re:Window showModaldialog HELP, Logan, January 27, 2004
             Re:Window showModaldialog HELP, Kiwi, January 27, 2004
                 Re:Window showModaldialog HELP, Erik Arvidsson, February 1, 2004
                     Re:Window showModaldialog HELP, Mattes, March 7, 2004

Subject: Re:Window showModaldialog HELP From: Mattes Date: March 7, 2004

Maybe this issue got out of interest meanwhile, but here's just a way you can handle that:

You need 2 things:
1. A Script file where all your function are in. In the following example everything is stored in an object called GuiControl. At the end, we want to have an easy to handle function like openPopUp and we don't want to care about maintainance - hope i am right abuot that ;-)
2. A HTML file acting as a dummy framework. This file is called first by showModalDialog. In the example it's name is popup.htm.

It works like this:
1. You define something like
<div id="content2004">I am the content for the modal Dialog</div>

2. Call gc.openPopUp("content2004", 400, 400).

3. openPopUp opens a modal dialog passing the guiControl object to that dialog window.

4. The dialog load popup.htm does nothing interesting than calling openPopUpFinish after loading. BUT it's passing it's document object back to the guiControl by using it as a parameter of openPopUpFinish.

5. Now openPopUpFinish can replace the source. Done!


The Script Source:

window.guiControl = new GuiControl();
var gc = window.guiControl; // This is rather done in your document (which loads this script file) to have a shortcut.

function GuiControl() {
  // Doesn't matter what's in there for this example

// We are assuming that the html source for the modal dialog lies in an document object, e.g a DIV. The id of that object is passed as an argument. Width and Height are optional and determine the size of the dialog window.
// Agreeing with erik the important thing is to pass the object window.guiControl as the second parameter of showModalDialog.

var popUp, popUpContent, popUpWidth, popUpHeight;

GuiControl.prototype.openPopUp = function(id, width, height) {
  if ( document.getElementById(id) ) {
    popUpContent = document.getElementById(id);
    popUpWidth  = ( width  > 0 ) ? width  : 500;
    popUpHeight  = ( height > 0 ) ? height : 600;  
    popUp    = window.showModalDialog("popup.htm", window.guiControl, "dialogWidth:"+popUpWidth+"px; dialogHeight:"+popUpHeight+"px; center:yes; scroll:no; help:no; resizable:no; status:no;");

  } else {
    alert( "Could not ......" );

// openPopUpFinish is called after loading popup.htm

GuiControl.prototype.openPopUpFinish = function(doc) {
 doc.body.innerHTML = popUpContent.innerHTML;
 // Here you can do other things like resize fixes etc.

The HTML Dummy Framework:

var gc; // References to GuiControl
function init() {
 gc = window.dialogArguments;
<body onLoad="init()">I will be replaced by the "real" source!</body>


..... but why does the png-behaviour fail in a modal dialog? ;-)



From: Erik Arvidsson
Sent: Feburary 1, 2004
Subject: Re:Window showModaldialog HELP

Kiwi is right here. You can get around this by passing a reference type as the argument to the dialog. Something like this

window.showModalDialog( "code to generate page that uses dialogArguments", window,'dialogHeight:400px;dialogWidth:600px;edge:Raised;center:Yes;help:No;resizable:Yes;status:No')

Since window is a reference to the page opening the dialog you can get the text you want using dialogArguments.varibleName where variableName contains the information you need.

However, this will soon become a maintainance nightmare and I do relly recommend that you use a static html page that you change depending on the dialogArguments.



Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.

View All Messages
Back to WebFX