jQuery对话框+ iframe在IE9中给出了这个错误:SCRIPT5009:'Array'未定义

Jea*_*amp 4 iframe jquery internet-explorer-9

我一直在与一个错误争夺一段时间,我只能用IE9.根据jQuery和jQuery-UI的版本,错误消息会有所不同.使用jquery 1.8.3和jquery-ui 1.8.24,我会收到以下错误消息:

SCRIPT5009:'Array'未定义

但是,使用jquery 1.7.x和jquery-ui 1.7.x,我会收到以下错误消息:

SCRIPT5009:'对象'未定义

以下是违规页面的代码:

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.8.24/jquery-ui.min.js"></script>
<title></title>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#dialog").dialog();
        });
    </script>
</head>
<body>
    <div id="dialog">
        <iframe id="iframe1" src="jqtest2.htm"></iframe>
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

以下是该页面中iframe的代码:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script>
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我没有在IE 9中使用兼容性视图模式,谷歌浏览器或Firefox中收到这些错误消息.

iframe中的jquery包含似乎是罪魁祸首.

Jea*_*amp 5

这是我如何解决我的问题.我将iframe src属性留空了,只有在调用dialog()之后才使用jquery初始化它.我想,这种方式IE稍后会加载iframe内容,在这种情况下,问题不会出现.以下是修改后的代码:

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.8.24/jquery-ui.min.js"></script>
<title></title>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#dialog").dialog();
            $("#iframe1").attr("src", "jqtest2.htm");
        });
    </script>
</head>
<body>
    <div id="dialog">
        <iframe id="iframe1" src=""></iframe>
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

iframe html文件保持不变.