【问题标题】:jQuery datepicker not working in IE8jQuery datepicker 在 IE8 中不起作用
【发布时间】:2013-06-12 15:22:27
【问题描述】:

为什么在 IE8 中出现以下错误?它在 Chrome 中运行良好:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.10.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>

<script type="text/javascript" language="javascript">

    $(document).ready(function() {

        $("#txtDate").datepicker({
            changeMonth: true,
            changeYear: true,
            yearRange: "+0:+1",
            showButtonPanel: false,
            dateFormat: "dd/mm/yy",
            showOn: "button",
            buttonImage: "../../images/Calendar.png",
            buttonImageOnly: true
        });

    });

</script>

所以在 Chrome 中绝对没有问题,但是 IE8 给了我以下错误:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; chromeframe/27.0.1453.110; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.0.3705; InfoPath.1; .NET4.0C; .NET4.0E)
Timestamp: Wed, 12 Jun 2013 15:18:48 UTC

Message: 'length' is null or not an object
Line: 139
Char: 17
Code: 0
URI: http://intranet/aspnet_client/system_web/1_1_4322/WebUIValidation.js

虽然日期选择器仍然有效,但当我单击图标时它会弹出,我可以选择一个日期,日期会出现在文本框中。但是当我点击日期时,日期选择器应该会消失,但它没有,而是显示上述错误。

有什么想法吗?

【问题讨论】:

  • 你碰巧在使用 ASP..?
  • @AndrewPeacock,是的,更新了标签!
  • 看来问题出在 ASP 上,而不是 JS。或者更确切地说,问题似乎出在您的 WebUIValidation.js 文件中。
  • 正如其他人所说的 ASP.Net 客户端验证存在干扰,请尝试在页面加载时禁用所有验证器,并在提交按钮上启用所有验证器并触发它们进行客户端验证。跨度>

标签: jquery asp.net jquery-ui internet-explorer-8 .net-1.1


【解决方案1】:

显然是 jQuery 中的一个错误。我刚刚向 jQuery datepicker 的“onSelect”事件添加了一个什么都不做的事件处理程序,它运行良好。下面是修改后的jQuery代码:

$(document).ready(function () {
    $("#txtDate").datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange: "+0:+1",
        showButtonPanel: false,
        dateFormat: "dd/mm/yy",
        showOn: "button",
        buttonImage: "../../images/Calendar.png",
        buttonImageOnly: true,
        onSelect: function () { }
    });

});

我在 IE 10 中也遇到了错误。让我知道它是否有效。

【讨论】:

  • 另请注意,在 jQuery 2.x 中放弃了对 IE 6/7/8 的支持。
猜你喜欢
  • 1970-01-01
  • 2011-04-25
  • 1970-01-01
  • 1970-01-01
  • 2011-09-03
  • 2013-06-18
  • 2012-09-12
  • 2012-07-08
  • 1970-01-01
相关资源
最近更新 更多