We are not able to get return value from chrome browser directly, because chrome is not understand then window.returnValue directly.
We have to create one object and assign all values into that object and that object will pass into open window params as below
function ShowModal() {
var forename = document.getElementById("forename");
var surname = document.getElementById("surname");
var sharedObject = new Object();
sharedObject.forename = forename.value;
sharedObject.surname = surname.value;
if (window.showModalDialog) {
var retValue = showModalDialog("model.html", sharedObject, "dialogWidth:200px; dialogHeight:200px; dialogLeft:300px;");
if (retValue) {
UpdateFields(retValue.forename, retValue.surname);
}
}
else {
var modal = window.open("model.html", null, "width=200,height=200,left=300,modal=yes,alwaysRaised=yes", null);
modal.dialogArguments = sharedObject;
}
}
after that we are able to get that object on model window, and assign that value to textbox or any othr container
var sharedObject = window.dialogArguments;
var forename = document.getElementById("forename");
var surname = document.getElementById("surname");
forename.value = sharedObject.forename;
surname.value = sharedObject.surname;
if we want to return value from the model value need to do code as below, UpdateFileds function must into parent window.
var forename = document.getElementById("forename");
var surname = document.getElementById("surname");
if (window.showModalDialog) {
var sharedObject = {};
sharedObject.forename = forename.value;
sharedObject.surname = surname.value;
window.returnValue = sharedObject;
}
else {
window.opener.UpdateFields(forename.value, surname.value);
}
window.close();
function UpdateFields(newFore, newSur) {
var forename = document.getElementById("forename");
var surname = document.getElementById("surname");
forename.value = newFore;
surname.value = newSur;
}
Note :Run code using virtual directory only other wise it is not going to work.
Enjoy Coding