Datejs - Problem with 12:00 pm

喜欢而已 提交于 2019-12-05 06:03:56

Download the latest version of Datejs from SVN not the version in the "download" section.

Try wrapping the code in an IIFE.

<!DOCTYPE html>
<html>
    <body>
        <input type=text id=d onkeyup="parsedate()">
        </input>
        <br>
        <span id=output></span>
        <script type="text/javascript" src="../../../static/js/date.js"></script>
        <script>
            ( function() {
                    parsedate = function() {
                        var input = document.getElementById('d').value;
                        var output = document.getElementById('output');
                        var d = Date.parse(input);
                        if (d !== null) {
                            output.innerHTML = d.toString();
                        } else {
                            output.innerHTML = "------"
                        }
                    }
                }());
        </script>
    </body>
</html>

The IIFE being

(function(){
    //code
}());

What I'm curious about is why FireFox behaves this way. I know they added security updates a few years back that prevent you from overwriting Date.prototype functions, but why is an IIFE capable of accessing this scope?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!