【问题标题】:"Microsoft JScript runtime error: Unable to get value of the property 'html':“Microsoft JScript 运行时错误:无法获取属性‘html’的值:
【发布时间】:2020-02-27 15:02:35
【问题描述】:

如果会话超时并且我的控制器返回一些错误消息,我会尝试弹出一条消息。

我的包含如下......

<link rel="stylesheet" type="text/css" href="<%= ResolveUrl("~/Content/jqueryui/redmond/jquery-ui-1.8.16.custom.css") %>"/>
<link rel="stylesheet" type="text/css" href="<%= ResolveUrl("~/css/slideshow.css") %>"/>   
<script type="text/javascript" src="<%= Url.Content("~/Scripts/ui/jquery-1.6.2.js") %>"></script>
<script type="text/javascript" src="<%= Url.Content("~/Scripts/ui/jquery-ui-1.8.16.custom.js") %>"></script>

代码如下:

<% 
        string AlertMessage2 = TempData["PublicAlertMessage"] as string;
        string AlertMessage2Title = TempData["AlertMessageTitle"] == null ? String.Empty : TempData["AlertMessageTitle"] as string;

        if( AlertMessage2 != null )
        { %>
          <div id="AlertMessage" title="">

             </div>
         <script type="text/javascript">
             jQuery.noConflict();
                 $("#AlertMessage").html("<center><%= AlertMessage2 %></center>");
                 $("#AlertMessage").dialog({ height: 240, width: 350, modal: true, title: '<%= AlertMessage2Title %>', buttons: { "OK": function () { $(this).dialog("close"); } } });

             });
          </script>

      <% } %>

当我实现以下 Jquery 对话框时,我收到“Microsoft JScript 运行时错误:无法获取属性 'html' 的值:对象为空或未定义”。

我是否缺少任何包含文件?我不知道在哪里看!有什么想法吗?

谢谢!

现在我可以看到模态窗口...但是在确定按钮中出现错误“Microsoft JScript 运行时错误:对象不支持属性或方法'对话框'”

这是在 IE 9 中。当我在 Google chrome 中尝试时,我无法关闭模式窗口。

$("#AlertMessage").dialog({
                     height: 200,
                     width: 250,
                     modal: true,
                     title: '<%= AlertMessage2Title %>',
                     buttons: { "OK": function () { 
                    // $(this).dialog('close'); --> comment this and try to run... no issues
                     } } });

按钮有什么问题?

29日更新:如果我去掉ok的关闭功能,就没有错误了。但是如何关闭模态窗口?还有其他解决方法吗?

12 月 2 日更新: 此代码在 IE 8 和 IE 9 中不起作用。弹出窗口也不会关闭。但在 IE 7 中没有问题。

【问题讨论】:

  • 为什么将 jQuery UI 包含为八个独立的 JavaScript 文件而不是一个?
  • 另外:&lt;center&gt; 标签是 1997 年的。

标签: jquery asp.net-mvc-2


【解决方案1】:

我认为您错过了 jQuery Ui 对话框使用的依赖项:

UI Core
**UI Position**
UI Widget
UI Mouse (Optional; only needed if using UI Draggable or UI Resizable)
UI Draggable (Optional)
UI Resizable (Optional)

http://jqueryui.com/demos/dialog/

如果您想包含整个 jQuery UI 套件,您可以创建一个独特的文件并包含它。

【讨论】:

  • 是的,我读到主要依赖项是核心、位置和小部件。我添加并运行了代码。我仍然得到同样的错误!
  • 你使用什么版本的jQuery,1.6.2?你可以试试1.7吗? jQuery UI 的 del 是什么?这是一个“快速”的工作小提琴jsfiddle.net
  • 版本 1.6.2。我用谷歌搜索了这个错误。有人评论说它需要某种顺序才能包含 js 文件。现在我看到了模型窗口,但 OK 按钮的 .dialog 上仍然出现错误! jQuery Ui 1.8.16.custom.js
  • 您可以尝试使用完整的 1.8.6 自定义吗?没有拆分的 UI js 文件
  • 我更喜欢使用聊天,但你不能加入。那么请尝试使用 jQuery 1.7 吗?
猜你喜欢
  • 1970-01-01
  • 2013-07-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多