Script isn't answering any more error using mo

2019-07-11 18:42发布

问题:

I am using the library morris.js http://www.oesmith.co.uk/morris.js/ in order to create charts for a website. It works on Opera, Internet Explorer and Google Chrome.

In Firefox, it randomly crashes instantly.

Script Panel tells me, it crashes here:

secondsSpecHelper = function(interval) {
    return {
        span: interval * 1000,
        start: function(d) {
        return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(),     
        d.getMinutes());
    },
fmt: function(d) {
    return "" + (Morris.pad2(d.getHours())) + ":" + (Morris.pad2(d.getMinutes())) + ":" + 
    (Morris.pad2(d.getSeconds()));
},
incr: function(d) {
    return d.setUTCSeconds(d.getUTCSeconds() + interval);
}
};

Any ideas, if any of those functions are NOT working in Firefox? Or what could cause this crash?

I get the standard Firefox Error:

Script isn't answering anymore..

回答1:

Fixed! Morris.js and Mozilla tries to parse the "xLabels" attribute as a Datetime, and goes into a forever-loop then.

Fixed with the attribute

    parseTime: false

For example:

xxx = new Morris.Line({
    xLabels: 'day',
    parseTime: false
});