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 trigger SCRIPT5011 Can't execute code from a freed script
error (alert
uses toString()
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 even alert(modal_return_value[n])
would work.
Or you can create a new array from the return value, something like this:
var arr = showModalDialog('returnsArray.htm');
if (!arr) {/* Dialog cancelled, do something */}
arr = Array.prototype.splice.call(arr, 0);
In the last line we borrow the splice
method of Array.prototype
and create a new array from the returned array.