From showmodaldialog window.returnValue
in Firefox I am getting array object, but in IE and Chrome getting error.
function doYes() {
var val=[];
val.push("A");
val.push("B");
window.returnValue =val;
}
Even array works in Firefox not in IE9. Please see the piece of code in showModalDialog
box.
function doYes() {
var val={};
val.x="A";
val.y="B";
window.returnValue =val;
}
This also works in Firefox not in IE9.
Since Chrome37,
showModalDialog
has been obsoleted. If you're using older Chrome, please read this SO answer.In IE11: If dialog's return value is either an array or an object, it can't access the properties in its prototype. This causes for example
alert(modal_return_value)
to fail and triggerSCRIPT5011 Can't execute code from a freed script
error (alert
usestoString()
method in the prototype).Somehow this is even understandable since the prototype actually is in a window, which was closed before you will access these properties. I'm not sure if this is a bug or an intended feature in IE11, but either way it's annoying.
You can access to the own properties of the returned object though. For example you can iterate through an array using a
for
loop, and evenalert(modal_return_value[n])
would work.Or you can create a new array from the return value, something like this:
In the last line we borrow the
splice
method ofArray.prototype
and create a new array from the returned array.