window.openDialog jest rozszerzeniem do Zachowuje się w taki sam sposób, oprócz tego, że opcjonalnie pobiera jeden lub więcej parametrów przeszłego windowFeatures i windowFeatures itself is treated a little differently.

The optional parameters, if present, will be bundled up in a JavaScript Array object and added to the newly created window as a property named window.arguments. They may be referenced in the JavaScript of the window at any time, including during the execution of a load handler. These parameters may be used, then, to pass arguments to and from the dialog window.

Note that the call to openDialog() returns immediately. If you want the call to block until the user has closed the dialog, supply modal as a windowFeatures parameter. Note that this also means the user won't be able to interact with the opener window until he closes the modal dialog.


newWindow = openDialog(url, name, features, arg1, arg2, ...)
Otwarte okno.
Adres URL który będzie wczytany do nowego okna.
Nazwa okna (opcjonalnie). Zobacz opis, aby dowiedzieć się więcej.
Zobacz opis, aby dowiedzieć się więcej.
arg1, arg2, ... 
Argumenty dopasowujące nowe okno (opcjonalnie).


var win = openDialog("http://example.tld/zzz.xul", "dlg", "", "pizza", 6.98);


Nowe możliwości

all - Initially activates (or deactivates ("all=no")) all chrome (except the behaviour flags chrome, dialog and modal). These can be overridden (so "menubar=no,all" turns on all chrome except the menubar.) This feature is explicitly ignored by window.openDialog finds it useful because of its different default assumptions.

Domyślne zachowanie

Możliwości chrome i dialog są zawsze assumed on, unless explicitly turned off ("chrome=no"). openDialog treats the absence of the features parameter as does, (that is, an empty string sets all features to off) except chrome and dialog, which default to on. If the features parameter is a zero-length string, or contains only one or more of the behaviour features (chrome, dependent, dialog and modal) the chrome features are assumed "OS' choice." That is, window creation code is not given specific instructions, but is instead allowed to select the chrome that best fits a dialog on that operating system.

Passing extra parameters to the dialog

To pass extra parameters into the dialog, you can simply supply them after the windowFeatures parameter:

openDialog("http://example.tld/zzz.xul", "dlg", "", "pizza", 6.98);

The extra parameters will then get packed into a property named arguments of type Array, and this property gets added to the newly opened dialog window.

To access these extra parameters from within dialog code, use the following scheme:

var food  = window.arguments[0];
var price = window.arguments[1];

Note that you can access this property from within anywhere in the dialog code.

Zwracanie wartości z okienka dialogowego

Since window.close() erases all properties associated with the dialog window (i.e. the variables specified in the JavaScript code which gets loaded from the dialog), it is not possible to pass return values back past the close operation using globals (or any other constructs).

To be able to pass values back to the caller, you have to supply some object via the extra parameters. You can then access this object from within the dialog code and set properties on it, containing the values you want to return or preserve past the window.close() operation.

var retVals = { address: null, delivery: null };
openDialog("http://example.tld/zzz.xul", "dlg", "modal", "pizza", 6.98, retVals);

If you set the properties of the retVals object in the dialog code as described below, you can now access them via the retVals array after the openDialog() call returns.

Inside the dialog code, you can set the properties as follows:

var retVals = window.arguments[2];
retVals.address  = enteredAddress; = "immediate";

Zobacz także .


DOM Level 0. Nie jest częścią żadnego standardu.