dialogArguments
Summary
Gets the arguments that are specified when showModalDialog is called.
Property of dom/WindowModaldom/WindowModal
Syntax
var arguments = window.dialogArguments;
window.dialogArguments = value;
Examples
The following example shows how to get information passed into a modal dialog window by using the dialogArguments property. The code corresponds to two different files. One file launches the modal window and the other file stores the code for the modal window.
This file launches the modal window and then sends an object to that modal window.
<!doctype html>
<html>
<head>
<script>
function fnLaunch() {
var aForm;
aForm = document.getElementById("oForm").elements;
var myObject = {};
myObject.firstName = aForm.oFirstName.value;
myObject.lastName = aForm.oLastName.value;
// The object "myObject" is sent to the modal window.
window.showModalDialog("modalDialogSource.htm", myObject, "dialogHeight:300px; dialogLeft:200px;");
}
</script>
</head>
<body>
<button onclick="fnLaunch();">Launch The Dialog</button>
<form id= "oForm">
First Name:
<input type="text" name="oFirstName" value="Jane">
<br/>
Last Name:
<input type="text" name="oLastName" value="Smith">
</form>
</body>
</html>
This file (modalDialogSource.htm), stores the code for the modal window. Get the object sent to this modal window by using the dialogArguments property.
<!doctype html>
<html>
<head>
<script>
var oMyObject = window.dialogArguments;
var sFirstName = oMyObject.firstName;
var sLastName = oMyObject.lastName;
</script>
<title>Untitled</title>
</head>
<body style="font-family: arial; font-size: 14pt; color: Snow;
background-color: RosyBrown;">
First Name:
<span style="color:#00ff7f">
<script>
document.write(sFirstName);
</script>
</span>
<br/>
Last Name:
<span style="color:#00ff7f">
<script>
document.write(sLastName);
</script>
</span>
</body>
</html>
Notes
This property applies only to windows that are created with the showModalDialog method.
Attributions
Mozilla Developer Network : [dialogArguments Article]
Microsoft Developer Network: [dialogArguments Property Article]