window.onload在IE8中不起作用

本文关键字:不起作用 IE8 onload window | 更新日期: 2023-09-27 17:58:46

我正在打开一个子弹出窗口,并从子窗口调用父函数。但我无法在IE8上做到这一点。我认为childwindow.onload的问题是有其他选择吗?

父级

function CallPopUp(rowindex,controlname ) {
            var childWindow = open('test1.aspx', '1397127848655', 'resizable=no,width=700,height=500');
            childWindow.onload = function () {
                var hidden1 = childWindow.document.getElementById('hidden1');
                var hidden2 = childWindow.document.getElementById('hidden2');
                alert('asdas');
                hidden1.innerHTML = rowindex;
                hidden2.innerHTML = controlname;
            }
        }

<span id="hidden1"></span>
        <span id="hidden2"></span>
       <script language="javascript" type="text/javascript">
           function updateParent(code, description) {
               var id = document.getElementById('hidden1').innerHTML;
               var controlname = document.getElementById('hidden2').innerHTML;
               window.opener.setValue(id,controlname,code,description);
               window.close();
               return false;
           }
           $(document).on('click', '.submit', function () {
               updateParent($(this).closest('tr').find('td:eq(0)').text(), $(this).closest('tr').find('td:eq(1)').text());
               return false;
           })
    </script>

window.onload在IE8中不起作用

尝试在onload函数的末尾添加分号,例如:

function CallPopUp(rowindex,controlname ) {
        var childWindow = open('test1.aspx', '1397127848655', 'resizable=no,width=700,height=500');
        childWindow.onload = function () {
            var hidden1 = childWindow.document.getElementById('hidden1');
            var hidden2 = childWindow.document.getElementById('hidden2');
            alert('asdas');
            hidden1.innerHTML = rowindex;
            hidden2.innerHTML = controlname;
        };
    }

我之前在IE8中也遇到过类似的问题,原因就在于此。