"Unable to execute code from freed script" in IE8 using Javascript w / Prototype

This is my first question here, like this.

I have a problem in IE8 where I have a popup form ( window.showDialog()) used to edit receipt information in an accounting system.

This worked fine until I had to add more content by adding a dynamically generated table of input fields. I get the information back to the array, however, where my error seems to be happening. var pinputs = [];- this is what seems to be causing the problem.

js in popup form:

function saveForm() {
if($('user_id')){
    var user_id = $F('user_id');
} else {
    var user_id = 0;
}
var payments = $$('.payment');
var pinputs = [];
for(var i=0; i<payments.length; i++){
    pinputs.push($F(payments[i]));
}
window.returnValue = {received_of: $F('received_of'), user_id: user_id,
                    note: $F('note'), work_date: $F('work_date'), payment: pinputs};
window.close();
}

js in the parent js file:

function modifyReceiptInformation(id) {
return window.showModalDialog('mod.php?mod=receipts&mode=receipt_edit_popup&wrapper=no&receipt_id=' + id, 'Modify Receipt',"dialogWidth:600px;dialogHeight:500px");
}

, , . , ? JS, .

- Edit -

, var payments = $$('.payment'); - .

+3
2

, , . , .

, :

  • script. , , , (, [].concat(popupArray), ), .

  • , /. JSON.stringify()/JSON.parse() , IE6/7. , script (, IE.)

+4

, .

// The array problem is when modalDialogue return values are arrays.  The array functions
// such as slice, etc... are deallocated when the modal dialogue closes.  This is an IE bug.
// The easiest way to fix this is to clone yourself a new array out of the remnants of the old.
//
// @param[in] ary
//   The array, which has been passed back from a modal dialogue (and is broken) to clone
// @returns
//   A new, unbroken array.
function cloneArray(ary) {
    var i;
    var newAry = [];
    for(i=0; i<ary.length; i++){
        if(Object.prototype.toString.call(ary[i]) == '[object Array]') {
            newAry.push(cloneArray(ary[i]));
        } else{
            newAry.push(ary[i]);
        }
    }
    return newAry;
}

:

var selectedAry = window.showModalDialog("Window.jsp", inputAry, "dialogWidth:900px; dialogHeight:700px; center:yes; resizable: yes;");
var newAry = cloneArray(selectedAry);
+4

Source: https://habr.com/ru/post/1787533/


All Articles