IE 8,9,10在window.open

时间:2015-07-18 12:55:07

标签: javascript jquery html internet-explorer jquery-plugins

我试图从parent.submitData()方法解析DOM元素 使用.replaceWith()方法使用以下代码段。

它适用于Firefox和Chrome。但我不知道为什么它不适用于IE 8,9,10。

在执行期间,IE 8,9,10抛出错误“没有支持这样的接口。”

jQuery版本:1.10.1

Parent.html

 <html>
        <head>

            <SCRIPT language=JavaScript src="/POCes/scripts/jquery-1.10.1.min.js">
            </SCRIPT>
            <SCRIPT language=JavaScript src="/POCes/scripts/jquery-migrate-1.2.1.min.js">
            </SCRIPT>
            <SCRIPT language=JavaScript src="/POCes/scripts/jquery-ui.js">
            </SCRIPT>
            <SCRIPT language=JavaScript src="/POCes/scripts/datePicker.js">
            </SCRIPT>
            <SCRIPT language=JavaScript src="/POCes/scripts/jquery.scrollableFixedHeaderTable.js">
            </SCRIPT>
            <SCRIPT language=JavaScript src="/POCes/scripts/jquery.blockUI.js">
            </SCRIPT>
            <script type="text/javascript" src="/POCes/scripts/serialize.js">
            </script>

            <script>
                 var myWindow = '';

                function myFunction() {

                   myWindow = window.open("/POCes/view/child.html", "", "width=500, height=500");
                }

                function submitData(chdwndObj,fileContent) {
                    chdwndObj.close();
                    $('#theFile').replaceWith(fileContent);
                }   

            </script>
        </head>

        <body>

            <p>Parent browser window</p>

            <div id ="theFile" > <div/>

            <button onclick="myFunction()">Try it</button>

        </body>
    </html>
----------------------------------------------------------------
Child.html

<!DOCTYPE html>
<html>
    <head>
        <script>
            var parentwindow = window.opener;

            function submitData() {

                if (document.forms[0].elements['theFile'].value == null ||
                    document.forms[0].elements['theFile'].value == "") {
                    alert("Please Select File");
                    return false;
                }

                    var fileContent = document.forms[0].elements['theFile'];
                     parentwindow.submitData(window,fileContent);
            }

        </script>
    </head>

    <body>
        <form>
            <p>Child browser window</p>

            <input type = "file" id = "theFile" name = "theFile"/>
            <input type ="button" onclick = "submitData()" value = "Save Me"/>
        </form>
    </body>
</html>

有关详细信息,请转到屏幕截图。

请帮助解决此问题。提前谢谢。

enter image description here enter image description here

0 个答案:

没有答案