【问题标题】:jquery-ui dialog won't close in Internet Explorer on Facebookjquery-ui 对话框不会在 Facebook 上的 Internet Explorer 中关闭
【发布时间】:2012-05-29 19:16:45
【问题描述】:

我有一个 div,我正在制作一个对话框,然后在准备好文档时打开它。
对话框显示,但没有响应单击 x 关闭或单击确定按钮。

我正在使用 jquery-ui,以及由 themeroller 创建的自定义主题:http://jqueryui.com/themeroller/

如果我不将其作为 Facebook 应用程序运行,该代码在 IE 中可以运行,如果我使用不同的浏览器(Safari、Chrome、Firefox),它也可以作为 Facebook 应用程序运行。

IE java控制台显示jquery-ui代码报错:
脚本 16389:未指定的错误。
jquery-ui-1.8.20.custom.min.js,第 73 行字符 5487

代码如下:

    <head>
      <link type="text/css" href="/jquery/css/start/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
      <script type="text/javascript" src="/jquery/js/jquery-1.7.2.min.js"></script>
      <script type="text/javascript" src="/jquery/js/jquery-ui-1.8.20.custom.min.js"></script>

      <script type="text/javascript">
      function showPopup() {
        $( '#dialog' ).dialog('open');
      }

      $( function () {
        $('#dialog').dialog({ autoOpen: false, show: "blind", hide: "blind", buttons: { "OK": function() { $(this).dialog("close"); } } });
      }) ;
      </script>

      </head>
      <body>
      <script type="text/javascript">
      $(function(){showPopup();});
      </script> 

      <div id='dialog' style="display: none;" title='title of the dialog'>
      Dialog message
      </div>

      </body>

【问题讨论】:

  • 在黑暗中刺伤 - 您是否可能在代码中的某处留下了一些 console.log() 语句? IE 不太喜欢它——尤其是在调试控制台未打开的情况下。还有什么版本的 IE 会有很大的帮助...它不是 IE 6...我知道很多:P
  • 我目前可以用 IE9 重现这个。我也用 IE8 看到过它,但没有那个系统设置来重现它。此外,我可以在没有其他代码的隔离页面上重现它。

标签: jquery facebook internet-explorer dialog jquery-ui-dialog


【解决方案1】:

jquery-ui-1.8.20.custom.min.js 在 IE9 IFRAME 中有一个问题,它没有正确设置 .focus,很可能试图将焦点设置到页面的 body 元素而不是 IFRAME 本身的 body 标签。我通过为 IFRAME 正文标签设置一个 id 来解决这个问题。

body id="bodyTag"

然后在 document.ready 函数中,将焦点设置到 IFRAME 正文标记:

$("#bodyTag").focus();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多