0

Why is the following giving me an error in IE8? It works fine in 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>

So absolutely no issues with this in Chrome, but IE8 gives me the following error:

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

The datepicker still works though, it popsup when I click the icon, I can select a date and the date appears in the textbox. But when I click the date, the datepicker is supposed to disappear, but it doesn't, instead it displays the above error.

Any ideas?

4

1 回答 1

5

显然是 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 中也遇到了错误。让我知道它是否有效。

于 2013-06-12T19:03:52.877 回答